annotate src/CMakeLists.txt @ 42:997c54d8912c

fix include dir
author kono
date Sat, 02 Mar 2019 19:06:28 +0900
parents
children b94d72292dfa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42
997c54d8912c fix include dir
kono
parents:
diff changeset
1 cmake_minimum_required(VERSION 3.8)
997c54d8912c fix include dir
kono
parents:
diff changeset
2
997c54d8912c fix include dir
kono
parents:
diff changeset
3 set(USE_CUDA,0)
997c54d8912c fix include dir
kono
parents:
diff changeset
4 # -DUSE_CUDA
997c54d8912c fix include dir
kono
parents:
diff changeset
5 # add_definitions("-Wall -g -O")
997c54d8912c fix include dir
kono
parents:
diff changeset
6
997c54d8912c fix include dir
kono
parents:
diff changeset
7 set(CMAKE_C_COMPILER $ENV{CBC_COMPILER})
997c54d8912c fix include dir
kono
parents:
diff changeset
8 add_definitions("-Wall -g")
997c54d8912c fix include dir
kono
parents:
diff changeset
9
997c54d8912c fix include dir
kono
parents:
diff changeset
10 # -DCMAKE_BUILD_TYPE=Debug
997c54d8912c fix include dir
kono
parents:
diff changeset
11 set(CMAKE_C_FLAGS_DEBUG "-O0")
997c54d8912c fix include dir
kono
parents:
diff changeset
12
997c54d8912c fix include dir
kono
parents:
diff changeset
13 if (${USE_CUDA})
997c54d8912c fix include dir
kono
parents:
diff changeset
14 include_directories("/usr/local/cuda/include")
997c54d8912c fix include dir
kono
parents:
diff changeset
15 set(NVCCFLAG "-std=c++11" "-g" "-O0" )
997c54d8912c fix include dir
kono
parents:
diff changeset
16 if (UNIX AND NOT APPLE) # LINUX
997c54d8912c fix include dir
kono
parents:
diff changeset
17 set(CUDA_LINK_FLAGS "-L/usr/local/cuda/lib64 -lcuda -lcudart")
997c54d8912c fix include dir
kono
parents:
diff changeset
18 elseif (APPLE)
997c54d8912c fix include dir
kono
parents:
diff changeset
19 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")
997c54d8912c fix include dir
kono
parents:
diff changeset
20 endif()
997c54d8912c fix include dir
kono
parents:
diff changeset
21 find_package(CUDA REQUIRED)
997c54d8912c fix include dir
kono
parents:
diff changeset
22 SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CUDA_LINK_FLAGS}" )
997c54d8912c fix include dir
kono
parents:
diff changeset
23 endif()
997c54d8912c fix include dir
kono
parents:
diff changeset
24
997c54d8912c fix include dir
kono
parents:
diff changeset
25 include_directories(".")
997c54d8912c fix include dir
kono
parents:
diff changeset
26
997c54d8912c fix include dir
kono
parents:
diff changeset
27 macro( GearsCommand )
997c54d8912c fix include dir
kono
parents:
diff changeset
28 set( _OPTIONS_ARGS )
997c54d8912c fix include dir
kono
parents:
diff changeset
29 set( _ONE_VALUE_ARGS TARGET )
997c54d8912c fix include dir
kono
parents:
diff changeset
30 set( _MULTI_VALUE_ARGS SOURCES )
997c54d8912c fix include dir
kono
parents:
diff changeset
31 cmake_parse_arguments( _Gears "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
997c54d8912c fix include dir
kono
parents:
diff changeset
32
997c54d8912c fix include dir
kono
parents:
diff changeset
33 set (_Gears_CSOURCES)
997c54d8912c fix include dir
kono
parents:
diff changeset
34 foreach(i ${_Gears_SOURCES})
997c54d8912c fix include dir
kono
parents:
diff changeset
35 if (${i} MATCHES "\\.cbc")
997c54d8912c fix include dir
kono
parents:
diff changeset
36 string(REGEX REPLACE "(.*).cbc" "c/\\1.c" j ${i})
997c54d8912c fix include dir
kono
parents:
diff changeset
37 add_custom_command (
997c54d8912c fix include dir
kono
parents:
diff changeset
38 OUTPUT ${j}
997c54d8912c fix include dir
kono
parents:
diff changeset
39 DEPENDS ${i}
997c54d8912c fix include dir
kono
parents:
diff changeset
40 COMMAND "perl" "gearsTools/generate_stub.pl" "-o" ${j} ${i}
997c54d8912c fix include dir
kono
parents:
diff changeset
41 )
997c54d8912c fix include dir
kono
parents:
diff changeset
42 list(APPEND _Gears_CSOURCES ${j})
997c54d8912c fix include dir
kono
parents:
diff changeset
43 elseif (${i} MATCHES "\\.cu")
997c54d8912c fix include dir
kono
parents:
diff changeset
44 string(REGEX REPLACE "(.*).cu" "c/\\1.ptx" j ${i})
997c54d8912c fix include dir
kono
parents:
diff changeset
45 add_custom_command (
997c54d8912c fix include dir
kono
parents:
diff changeset
46 OUTPUT ${j}
997c54d8912c fix include dir
kono
parents:
diff changeset
47 DEPENDS ${i}
997c54d8912c fix include dir
kono
parents:
diff changeset
48 COMMAND nvcc ${NVCCFLAG} -c -ptx -o ${j} ${i}
997c54d8912c fix include dir
kono
parents:
diff changeset
49 )
997c54d8912c fix include dir
kono
parents:
diff changeset
50 list(APPEND _Gears_CSOURCES ${j})
997c54d8912c fix include dir
kono
parents:
diff changeset
51 else()
997c54d8912c fix include dir
kono
parents:
diff changeset
52 set(j ${i})
997c54d8912c fix include dir
kono
parents:
diff changeset
53 endif()
997c54d8912c fix include dir
kono
parents:
diff changeset
54 endforeach(i)
997c54d8912c fix include dir
kono
parents:
diff changeset
55
997c54d8912c fix include dir
kono
parents:
diff changeset
56 add_custom_command (
997c54d8912c fix include dir
kono
parents:
diff changeset
57 OUTPUT c/${_Gears_TARGET}-context.c
997c54d8912c fix include dir
kono
parents:
diff changeset
58 DEPENDS ${_Gears_CSOURCES}
997c54d8912c fix include dir
kono
parents:
diff changeset
59 COMMAND "perl" "gearsTools/generate_context.pl" "-o" ${_Gears_TARGET} ${_Gears_CSOURCES}
997c54d8912c fix include dir
kono
parents:
diff changeset
60 )
997c54d8912c fix include dir
kono
parents:
diff changeset
61 add_executable(${_Gears_TARGET} ${_Gears_CSOURCES} c/${_Gears_TARGET}-context.c)
997c54d8912c fix include dir
kono
parents:
diff changeset
62 target_link_libraries(${_Gears_TARGET} m pthread)
997c54d8912c fix include dir
kono
parents:
diff changeset
63 endmacro()
997c54d8912c fix include dir
kono
parents:
diff changeset
64
997c54d8912c fix include dir
kono
parents:
diff changeset
65
997c54d8912c fix include dir
kono
parents:
diff changeset
66 GearsCommand(
997c54d8912c fix include dir
kono
parents:
diff changeset
67 TARGET
997c54d8912c fix include dir
kono
parents:
diff changeset
68 kernel
997c54d8912c fix include dir
kono
parents:
diff changeset
69 SOURCES
997c54d8912c fix include dir
kono
parents:
diff changeset
70 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
997c54d8912c fix include dir
kono
parents:
diff changeset
71 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
997c54d8912c fix include dir
kono
parents:
diff changeset
72 entry-osx.S
997c54d8912c fix include dir
kono
parents:
diff changeset
73 )
997c54d8912c fix include dir
kono
parents:
diff changeset
74
997c54d8912c fix include dir
kono
parents:
diff changeset
75
997c54d8912c fix include dir
kono
parents:
diff changeset
76