This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
77 lines (67 loc) · 2.92 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
cmake_minimum_required(VERSION 3.1)
project(spacemesh)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, defaulting to Release")
set(CMAKE_BUILD_TYPE "Release")
endif ()
if (APPLE)
option(SPACEMESHCUDA "Build with CUDA support" OFF)
# we should check here for ARM / Intel too
add_compile_definitions(SPACEMESH_VULKAN_COMPATIBILITY_NEEDED=1)
else()
option(SPACEMESHCUDA "Build with CUDA support" ON)
endif()
option(SPACEMESHVULKAN "Build with Vulkan support" ON)
option(SPACEMESH_LIB_SHARED "Build as shared library" ON)
# propagates CMake configuration options to the compiler
if (SPACEMESHCUDA)
add_definitions(-DHAVE_CUDA=1)
endif()
if (SPACEMESHVULKAN)
add_definitions(-DHAVE_VULKAN=1)
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
endif()
if (MSVC)
string(REGEX REPLACE "/W[3|4]" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FS")
# if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
# if (SPACEMESHVULKAN)
# # use release static runtime
# foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
# CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
# flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
# CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
#
# if (${flag_var} MATCHES "/MDd")
# string(REGEX REPLACE "/MDd" "/MT" ${flag_var} "${${flag_var}}")
# endif(${flag_var} MATCHES "/MDd")
# endforeach(flag_var)
# endif()
# else()
# # use static runtime
# foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
# CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
# flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
# CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
#
# if (${flag_var} MATCHES "/MD")
# string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
# endif(${flag_var} MATCHES "/MD")
# endforeach(flag_var)
# endif()
endif()
message("------------------------------------------------------------------------")
message("-- CMake ${CMAKE_VERSION}")
message("-- Build ${CMAKE_BUILD_TYPE} / ${CMAKE_SYSTEM_NAME}")
message("------------------------------------------------------------- components")
message("-- SPACEMESHCUDA Build CUDA components ${SPACEMESHCUDA}")
message("-- SPACEMESHVULKAN Build Vulkan components ${SPACEMESHVULKAN}")
message("------------------------------------------------------------------------")
message("")
if(UNIX AND NOT APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc -pthread")
endif()
add_subdirectory(src)
add_subdirectory(test)