This repository has been archived by the owner on Oct 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (56 loc) · 2.24 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
cmake_minimum_required(VERSION 3.1)
option(TOOLBOXCPP_TESTS "Add compilation of toolboxcpp's own unittests" OFF)
project(toolboxcpp)
# Works with CMake 3.1 and above
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
# Anyway, adjust compiler flags depending on its ID
# Underscores are used to prevent literals from being treated as variable names
if("_${CMAKE_CXX_COMPILER_ID}_" STREQUAL "_GNU_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
elseif("_${CMAKE_CXX_COMPILER_ID}_" STREQUAL "_Clang_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror")
elseif("_${CMAKE_CXX_COMPILER_ID}_" STREQUAL "_MSVC_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX")
endif()
set(SOURCES
include/toolboxcpp/log/Log.hpp
include/toolboxcpp/log/Logger.hpp
include/toolboxcpp/log/Combinators.hpp
include/toolboxcpp/log/Sinks.hpp
include/toolboxcpp/log/DefaultFmt.hpp
src/log/Logger.cpp
include/toolboxcpp/util/FuncRef.hpp
include/toolboxcpp/util/FoldTuple.hpp
include/toolboxcpp/util/SourceLocation.hpp
)
source_group(include\\toolboxcpp\\log FILES
include/toolboxcpp/log/Log.hpp
include/toolboxcpp/log/Logger.hpp
include/toolboxcpp/log/Combinators.hpp
include/toolboxcpp/log/Sinks.hpp
include/toolboxcpp/log/DefaultFmt.hpp
)
source_group(include\\toolboxcpp\\util FILES
include/toolboxcpp/util/FuncRef.hpp
include/toolboxcpp/util/FoldTuple.hpp
include/toolboxcpp/util/SourceLocation.hpp
)
source_group(src\\log FILES
src/log/Logger.cpp
)
add_library(toolboxcpp STATIC EXCLUDE_FROM_ALL ${SOURCES})
target_include_directories(toolboxcpp PUBLIC include PRIVATE src)
add_library(toolboxcpp_shared SHARED EXCLUDE_FROM_ALL ${SOURCES})
target_include_directories(toolboxcpp_shared PUBLIC include PRIVATE src)
if(TOOLBOXCPP_TESTS)
enable_testing()
add_subdirectory(catch2)
set(UNITTESTS Log)
foreach(I ${UNITTESTS})
add_executable(${I}_unittest test/${I}.cpp)
target_link_libraries(${I}_unittest toolboxcpp Catch2::Catch)
add_test(NAME "${I}-unittest" COMMAND $<TARGET_FILE:${I}_unittest>)
set_tests_properties("${I}-unittest" PROPERTIES DEPENDS ${I}_unittest)
endforeach()
endif()