-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
109 lines (88 loc) · 3.41 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
cmake_minimum_required(VERSION 3.14)
# *******************************************
# ************* CMake Content ***************
# *******************************************
# This CMake create a workspace containing the following projects
#
# Programs
# - pendulum
set (PROJECT_NAME pendulum)
project(${PROJECT_NAME})
option( TESTING "Is the program compiled for tests only (without display)." OFF)
# Add definition for relative path into project
add_definitions( -DPROJECT_ROOT_PATH="${CMAKE_CURRENT_SOURCE_DIR}")
# Disable C and C++ compiler extensions.
# C/CXX_EXTENSIONS are ON by default to allow the compilers to use extended
# variants of the C/CXX language.
# However, this could expose cross-platform bugs in user code or in the headers
# of third-party dependencies and thus it is strongly suggested to turn
# extensions off.
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT ${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
# Link with pthread
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
# Debug or release
if(CMAKE_BUILD_TYPE MATCHES "Debug")
MESSAGE("Generate Debug project")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Debug)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall")
else()
MESSAGE("Generate Release project")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Release)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
endif()
#add libmath during non visual studio builds
set(CMAKE_EXTRA_LIB m)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()
# Add definitions for testing purposes
if(${TESTING})
MESSAGE("Testing mode")
add_definitions(-DNO_CONSOLE_CONTROL -DNB_GENERATIONS=2)
endif()
# *******************************************
# *********** GEGELATI LIBRARY **************
# *******************************************
if(WIN32)
set(LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
# find the gegelatilib-x.y.z folder in the lib directory.
file(GLOB GEGELATI_ROOT_DIR "${LIBS_DIR}/gegelatilib-[\\.|0-9]*")
set(ENV{GEGELATI_DIR} ${GEGELATI_ROOT_DIR})
endif()
find_package(GEGELATI)
if (WIN32)
file(GLOB
GEGELATI_DLL
${GEGELATI_ROOT_DIR}/bin/*.dll
)
MESSAGE("Copy GEGELATI DLLs into ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
file(COPY ${GEGELATI_DLL} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
file(COPY ${GEGELATI_DLL} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug)
file(COPY ${GEGELATI_DLL} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release)
endif()
endif()
# *******************************************
# **************** Python *******************
# *******************************************
find_package(PythonLibs)
find_package(Python COMPONENTS Interpreter Development NumPy REQUIRED)
# *******************************************
# ************** Executable ****************
# *******************************************
# Executable to learn the TPG
file(GLOB_RECURSE
pendulum_files
./src/*.cpp
./src/*.h
./params.json
)
include_directories(${GEGELATI_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${Python_NumPy_INCLUDE_DIRS})
add_executable(${PROJECT_NAME} ${pendulum_files})
target_link_libraries(${PROJECT_NAME} ${GEGELATI_LIBRARIES} ${PYTHON_LIBRARIES})
target_compile_definitions(${PROJECT_NAME} PRIVATE ROOT_DIR="${CMAKE_SOURCE_DIR}")