generated from martin-olivier/CppTemplate
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
73 lines (58 loc) · 1.61 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
cmake_minimum_required(VERSION 3.17)
# The name of the CMake project
project(ziapi)
# The C++ standard you want to use for your project
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
option(UNIT_TESTS "When sets to ON, build the unit tests" OFF)
if(UNIT_TESTS)
# Fetch GoogleTest
find_package(googletest QUIET)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# The bin name for your unit tests
set(BIN unit_tests)
# The build flags
if(UNIX)
add_compile_options(-Wall -Wextra -Weffc++)
elseif(WIN32)
add_compile_options(/W4)
endif()
# The list of tests source files
set(TEST_SOURCES
tests/Logger.cpp
tests/Compressor.cpp
tests/Decompressor.cpp
tests/Config.cpp
tests/Module.cpp
tests/Version.cpp
)
add_executable(${BIN}
${SOURCES}
${TEST_SOURCES}
)
enable_testing()
include(GoogleTest)
gtest_discover_tests(${BIN})
target_link_libraries(${BIN} PRIVATE gtest_main)
if(UNIX)
target_link_libraries(${BIN} PRIVATE dl)
endif()
# The include path
include_directories(
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/examples/modules
${PROJECT_SOURCE_DIR}/examples/utils
)
add_library(module SHARED examples/dylib/Module.cpp)
set_target_properties(module PROPERTIES PREFIX "")
add_dependencies(${BIN} module)
endif()