-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
97 lines (82 loc) · 3.11 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
cmake_minimum_required(VERSION 3.5.0)
project(mimpc)
option(BuildSim "BuildSim" ON)
option(BuildExamples "BuildExamples" ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
set(LIB_VERSION_MAJOR 0 CACHE STRING "major version" FORCE)
set(LIB_VERSION_MINOR 1 CACHE STRING "minor version" FORCE)
set(LIB_VERSION ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR} CACHE STRING "version" FORCE)
message("Building mimpc library")
set(CMAKE_CXX_STANDARD 23)
set(LIBSOURCES
src/systems/REACSA.cpp
)
find_package(fmt REQUIRED)
find_package(SCIP REQUIRED)
if(BuildSim)
message("Building simulation related content")
set(SIMSOURCES
src/sim/VizForces.cpp
)
find_package(drake CONFIG REQUIRED)
find_package(ZLIB)
add_library(cnpy SHARED IMPORTED) # or STATIC instead of SHARED
set_target_properties(cnpy PROPERTIES
IMPORTED_LOCATION "/usr/local/lib/libcnpy.so"
INTERFACE_INCLUDE_DIRECTORIES "/usr/local/include"
)
endif()
set(LIB_INCLUDE_INSTALL_DESTINATION include/mimpc)
add_library(mimpclib ${LIBSOURCES})
target_include_directories(mimpclib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${MYLB_INCLUDE_INSTALL_DESTINATION}>)
target_include_directories(mimpclib PUBLIC ${SCIP_INCLUDE_DIRS})
target_link_libraries(mimpclib PUBLIC ${SCIP_LIBRARIES})
target_link_libraries(mimpclib INTERFACE ${SCIP_LIBRARIES} fmt::fmt)
if (BuildSim)
add_library(mimpclibsim ${SIMSOURCES})
target_include_directories(mimpclibsim PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${MYLB_INCLUDE_INSTALL_DESTINATION}>)
target_link_libraries(mimpclibsim INTERFACE mimpclib)
target_link_libraries(mimpclibsim PUBLIC drake::drake)
target_link_libraries(mimpclibsim INTERFACE cnpy)
target_link_libraries(mimpclibsim INTERFACE ZLIB::ZLIB)
target_link_libraries(mimpclibsim INTERFACE fmt::fmt)
endif ()
if(BuildExamples)
message("Building example related content")
set(EXAMPLESOURCES
examples/esa_reacsa/main.cpp
)
add_executable(reacsamimpc ${EXAMPLESOURCES})
target_link_libraries(reacsamimpc mimpclibsim)
target_include_directories(reacsamimpc PUBLIC ${SCIP_INCLUDE_DIRS})
target_include_directories(reacsamimpc PUBLIC include)
endif()
INSTALL(TARGETS mimpclib EXPORT mimpclib
# for executables and dll on Win
RUNTIME DESTINATION bin
# shared libraries
LIBRARY DESTINATION lib
# for static libraries
ARCHIVE DESTINATION lib
)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include" # source directory
DESTINATION "${LIB_INCLUDE_INSTALL_DESTINATION}" # target directory
)
INSTALL(EXPORT mimpclib
DESTINATION lib/cmake/mimpclib
FILE mimpclibConfig.cmake
NAMESPACE mimpclib::
)
target_compile_options(mimpclib PRIVATE -Werror -Wall -Wextra -pedantic)
if(BuildSim)
target_compile_options(mimpclibsim PRIVATE -Werror -Wall -Wextra -pedantic)
endif ()