Mercurial > hg > Members > menikon > CbC_xv6
diff src/CMakeLists.txt @ 42:997c54d8912c
fix include dir
author | kono |
---|---|
date | Sat, 02 Mar 2019 19:06:28 +0900 |
parents | |
children | b94d72292dfa |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/CMakeLists.txt Sat Mar 02 19:06:28 2019 +0900 @@ -0,0 +1,76 @@ +cmake_minimum_required(VERSION 3.8) + +set(USE_CUDA,0) +# -DUSE_CUDA +# add_definitions("-Wall -g -O") + +set(CMAKE_C_COMPILER $ENV{CBC_COMPILER}) +add_definitions("-Wall -g") + +# -DCMAKE_BUILD_TYPE=Debug +set(CMAKE_C_FLAGS_DEBUG "-O0") + +if (${USE_CUDA}) + include_directories("/usr/local/cuda/include") + set(NVCCFLAG "-std=c++11" "-g" "-O0" ) + if (UNIX AND NOT APPLE) # LINUX + set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart") + elseif (APPLE) + set(CUDA_LINK_FLAGS "-framework CUDA -lc++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names /usr/local/cuda/lib/libcudart_static.a -Wl,-rpath,/usr/local/cuda/lib") + endif() + find_package(CUDA REQUIRED) + SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" ) +endif() + +include_directories(".") + +macro( GearsCommand ) + set( _OPTIONS_ARGS ) + set( _ONE_VALUE_ARGS TARGET ) + set( _MULTI_VALUE_ARGS SOURCES ) + cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) + + set (_Gears_CSOURCES) + foreach(i ${_Gears_SOURCES}) + if (${i} MATCHES "\\.cbc") + string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i}) + add_custom_command ( + OUTPUT ${j} + DEPENDS ${i} + COMMAND "perl" "gearsTools/generate_stub.pl" "-o" ${j} ${i} + ) + list(APPEND _Gears_CSOURCES ${j}) + elseif (${i} MATCHES "\\.cu") + string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i}) + add_custom_command ( + OUTPUT ${j} + DEPENDS ${i} + COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i} + ) + list(APPEND _Gears_CSOURCES ${j}) + else() + set(j ${i}) + endif() + endforeach(i) + + add_custom_command ( + OUTPUT c/${_Gears_TARGET}-context.c + DEPENDS ${_Gears_CSOURCES} + COMMAND "perl" "gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CSOURCES} + ) + add_executable(${_Gears_TARGET} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c) + target_link_libraries(${_Gears_TARGET} m pthread) +endmacro() + + +GearsCommand( + TARGET + kernel + SOURCES + lib/string.c arm.c asm.S bio.c buddy.c console.cbc exec.c file.c fs.c log.c main.c memide.c pipe.c proc.c spinlock.c + start.c swtch.S syscall.c sysfile.c sysproc.c trap_asm.S trap.c vm.c device/picirq.c device/timer.c device/uart.c + entry-osx.S +) + + +