This repository has been archived by the owner on Sep 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
80 lines (72 loc) · 2.74 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
cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0054 NEW)
project(Zycore)
option(ZYCORE_FORCE_SHARED_CRT "Forces shared linkage against the CRT" FALSE)
option(ZYCORE_HEADER_ONLY "Configure for header-only library usage" FALSE)
option(ZYCORE_DEV "Enable ZyCore development mode (warnings -> errors, ...)" FALSE)
mark_as_advanced(ZYCORE_DEV)
if (ZYCORE_HEADER_ONLY)
add_definitions("-DZYCORE_HEADER_ONLY=1")
endif ()
# CMake always orders MSVC to build with a shared CRT. Hack CMake variables in order
# to generate with a statically linked CRT when we build as a static library.
if (MSVC AND NOT ZYCORE_FORCE_SHARED_CRT)
set(manipulated_vars
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO)
foreach(cur_var ${manipulated_vars})
string(REPLACE "/MD" "/MT" new_var "${${cur_var}}")
set(${cur_var} ${new_var} CACHE STRING "" FORCE)
endforeach()
endif ()
# Library
set(headers
"include/zycore/BinaryStream.hpp"
"include/zycore/Exceptions.hpp"
"include/zycore/Config.hpp"
"include/zycore/Operators.hpp"
"include/zycore/Optional.hpp"
"include/zycore/Property.hpp"
"include/zycore/ReflectableObject.hpp"
"include/zycore/Signal.hpp"
"include/zycore/SignalObject.hpp"
"include/zycore/Singleton.hpp"
"include/zycore/Mpl.hpp"
"include/zycore/Result.hpp"
"include/zycore/Types.hpp"
"include/zycore/TypeTraits.hpp"
"include/zycore/Utils.hpp")
set(sources
"src/BinaryStream.cpp"
"src/Property.cpp"
"src/ReflectableObject.cpp"
"src/SignalObject.cpp")
if (ZYCORE_HEADER_ONLY)
add_library("Zycore" INTERFACE)
target_include_directories("Zycore" INTERFACE "include/")
else ()
add_library("Zycore" ${headers} ${sources})
include_directories("include/")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(initial_compile_flags "-std=c++14")
if (ZYCORE_DEV)
set(initial_compile_flags "${initial_compile_flags} -Werror")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(initial_compile_flags "/W4 /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /GR-")
if (ZYCORE_DEV)
set(initial_compile_flags "${initial_compile_flags} /WX")
endif ()
endif ()
set(ZYCORE_COMPILE_FLAGS "${initial_compile_flags}"
CACHE STRING "Flags used when compiling the ZyCore library.")
mark_as_advanced(ZYCORE_COMPILE_FLAGS)
set_target_properties("Zycore" PROPERTIES COMPILE_FLAGS "${ZYCORE_COMPILE_FLAGS}")
endif ()