-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
78 lines (63 loc) · 2.73 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
78
cmake_minimum_required(VERSION 3.15)
project(Void_analyze)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(BUILD_TESTING TRUE)
#set(CMAKE_BUILD_TYPE "Release")
# if (CMAKE_BUILD_TYPE STREQUAL Debug)
add_compile_definitions("DEBUG")
# endif()
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
# Download automatically, you can also just copy the conan.cmake file
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.15/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif ()
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/include/timer.h")
message(STATUS "Downloading timer.h from https://github.com/MikeShi1993/SFT")
file(DOWNLOAD "https://raw.githubusercontent.com/MikeShi1993/SFT/master/include/timer.h"
"${PROJECT_SOURCE_DIR}/include/timer.h")
endif()
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/include/color.h")
message(STATUS "Downloading color.h from https://github.com/MikeShi1993/SFT")
file(DOWNLOAD "https://raw.githubusercontent.com/MikeShi1993/SFT/master/include/color.h"
"${PROJECT_SOURCE_DIR}/include/color.h")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_run(CONANFILE conanfile.txt # or relative build/conanfile.txt
BASIC_SETUP CMAKE_TARGETS
BUILD missing
SETTINGS cppstd=17)
if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else ()
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
endif ()
# find_package(pybind11 REQUIRED)
# find_package(PythonLibs REQUIRED)
# include_directories(${PYTHON_INCLUDE_DIRS})
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(STATUS ${CMAKE_CXX_COMPILER_VERSION})
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror=vla")
# target_compile_options(void_analyze PRIVATE -Werror=vla)
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8)
message(FATAL_ERROR "Insufficient g++ version")
elseif (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
target_link_libraries(void_analyze stdc++fs)
endif ()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
message(FATAL_ERROR "Insufficient msvc version")
endif ()
endif ()
include_directories("${PROJECT_SOURCE_DIR}/include")
add_subdirectory(${PROJECT_SOURCE_DIR}/src)
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
include(CTest)
enable_testing()
endif ()
if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_subdirectory(${PROJECT_SOURCE_DIR}/unit_test)
endif ()