-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (65 loc) · 3.2 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
cmake_minimum_required(VERSION 3.20)
project(cppmie)
set(PROJECT_VERSION 1.0.1)
set(PROJECT_HOMEPAGE_URL https://github.com/codesaurus97/cppmie)
# Require C++ 20 due to usage of concepts
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
include(GNUInstallDirs)
# --- Fetch Google Test for Unit Testing ---
include(FetchContent)
FetchContent_Declare(
googletest
# Specify the commit you depend on and update it regularly.
URL https://github.com/google/googletest/archive/e2239ee6043f73722e7aa812a459f54a28552929.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# --- Library Definition
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(
${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_20)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
install(EXPORT ${PROJECT_NAME}_Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME} DESTINATION include)
# --- Executable to run benchmark on the mie scattering calculation ----------------------------------------------------
# TODO: Add benchmark to the cmakelist without adding it to the library
enable_testing()
add_executable(test_mie_reference test/test_mie_reference.cc)
target_link_libraries(test_mie_reference PRIVATE cppmie gtest_main)
add_test(NAME "Mie Scattering Reference" COMMAND test_mie_reference)
# --- Benchmarks -------------------------------------------------------------------------------------------------------
#FetchContent_Declare(googlebenchmark
# GIT_REPOSITORY https://github.com/google/benchmark.git
# GIT_TAG master) # need master for benchmark::benchmark
#
#FetchContent_MakeAvailable(
# googlebenchmark)
#add_executable(bench_mie_reference benchmark/bench_mie_reference.cc)
#target_compile_options(bench_mie_reference PRIVATE "-fno-omit-frame-pointer")
#target_link_libraries(bench_mie_reference PRIVATE cppmie benchmark::benchmark)
#add_test(NAME "Benchmark Reference" COMMAND bench_mie_reference)