Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
78 lines (66 loc) · 2.11 KB
/
Copy pathCMakeLists.txt
File metadata and controls
78 lines (66 loc) · 2.11 KB
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.18)
project(moqm-tests)
# Set the C++ standard (mooutils requires C++20 for concepts/ranges)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Set the build type to Release by default
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Print the build type
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# Warning flags
set(MOQM_CXX_WARN_FLAGS "")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
list(APPEND MOQM_CXX_WARN_FLAGS
-Wall
-Wextra
-Wpedantic
)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
list(APPEND MOQM_CXX_WARN_FLAGS
-Wvector-operation-performance
-Wduplicated-cond
)
endif()
else()
message(WARNING "Unknown compiler, not setting any warning flags.")
endif()
# Add include directories
include_directories(${CMAKE_SOURCE_DIR}/include)
# Header-only quality metrics library (moqm)
add_library(moqm INTERFACE)
target_include_directories(moqm INTERFACE ${CMAKE_SOURCE_DIR}/include)
# Optional: link GLPK if found (needed only for classification.hpp)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(GLPK QUIET glpk)
endif()
if(NOT GLPK_FOUND)
find_library(GLPK_LIBRARY NAMES glpk)
if(GLPK_LIBRARY)
set(GLPK_FOUND TRUE)
endif()
endif()
if(GLPK_FOUND)
target_link_libraries(moqm INTERFACE glpk)
message(STATUS "GLPK found — classification.hpp available")
else()
message(STATUS "GLPK not found — classification.hpp will not be usable")
endif()
# mooutils: hypervolume computation backend
include(FetchContent)
FetchContent_Declare(
mooutils
GIT_REPOSITORY https://github.com/adbjesus/mooutils.git
GIT_TAG main
)
FetchContent_MakeAvailable(mooutils)
target_link_libraries(moqm INTERFACE mooutils)
# ---- moqm library tests (dependency-free, no GLPK needed) ----
enable_testing()
add_executable(test_moqm ${CMAKE_SOURCE_DIR}/tests/test_moqm.cpp)
target_link_libraries(test_moqm PRIVATE moqm)
target_compile_features(test_moqm PRIVATE cxx_std_20)
target_compile_options(test_moqm PRIVATE ${MOQM_CXX_WARN_FLAGS})
add_test(NAME moqm_tests COMMAND test_moqm)