-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
63 lines (52 loc) · 1.66 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
project(
myproject_core
VERSION 0.1.0
DESCRIPTION "Example library"
LANGUAGES CXX)
#
# Set our source and include directory variables for use through the build
#
set(PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(PACKAGE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(PACKAGE_TEST_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests")
#
# Add all source files
#
set(SOURCE_FILES "${PACKAGE_SOURCE_DIR}/core.cpp")
#
# Output build information
#
message(STATUS "Building ${PROJECT_NAME} in [${CMAKE_BUILD_TYPE}] mode")
#
# Add tests if in Debug mode
#
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Tests active for ${PROJECT_NAME}")
add_subdirectory(tests)
endif()
#
# Generate configuration file
#
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure_files/config.hpp.in
${PACKAGE_INCLUDE_DIR}/${PROJECT_NAME}/config.hpp)
#
# Create the library
#
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})
# Link required dependencies
target_link_libraries(${PROJECT_NAME} PRIVATE myproject_options myproject_warnings
fmt::fmt spdlog::spdlog)
target_include_directories(
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PACKAGE_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include>)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
set_target_properties(
${PROJECT_NAME}
PROPERTIES VERSION ${PROJECT_VERSION}
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN YES)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
run_clang_format(${PACKAGE_INCLUDE_DIR})
run_clang_format(${PACKAGE_SOURCE_DIR})
run_clang_format(${PACKAGE_TEST_DIR})
endif()