-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
56 lines (48 loc) · 2.02 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
cmake_minimum_required(VERSION 3.15.7)
project(ScipPP LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
option(USE_COVERAGE "Create coverage report." OFF)
option(BUILD_TESTS "Build tests." OFF)
option(BUILD_UTILS "Build utils." OFF)
message(STATUS "${PROJECT_NAME} version derived from git is ${scippp_version}")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/source/version.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/source/version.cpp)
find_package(scip CONFIG REQUIRED)
if (TARGET libscip)
add_library(scip::scip ALIAS libscip)
endif ()
# enable coverage analysis by setting USE_COVERAGE to ON
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(COVERAGE_COMPILER_FLAGS "-fprofile-instr-generate -fcoverage-mapping" CACHE INTERNAL "")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(COVERAGE_COMPILER_FLAGS "-fprofile-arcs -ftest-coverage -fPIC -O0 -g" CACHE INTERNAL "")
else ()
message(WARNING "We do not support coverage with this compiler: ${CMAKE_CXX_COMPILER_ID}")
endif ()
function(append_coverage_compiler_flags)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
message(STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}")
endfunction()
if (USE_COVERAGE)
append_coverage_compiler_flags()
endif ()
# Lib
file(GLOB SCIPPP_SRC source/*.cpp ${CMAKE_CURRENT_BINARY_DIR}/source/version.cpp)
file(GLOB SCIPPP_HDR include/**/*.hpp)
add_library(ScipPP ${SCIPPP_SRC})
target_include_directories(ScipPP PUBLIC include)
target_link_libraries(ScipPP PUBLIC scip::scip)
# install
include(GNUInstallDirs)
install(TARGETS ScipPP LIBRARY DESTINATION lib)
set_target_properties(ScipPP PROPERTIES PUBLIC_HEADER "${SCIPPP_HDR}")
install(TARGETS ScipPP PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/scippp)
if (BUILD_TESTS)
add_subdirectory(test)
endif ()
if (BUILD_UTILS)
add_subdirectory(utils)
endif ()