-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
105 lines (71 loc) · 2.34 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#==============================================================================
# Top-Level CoreZero.SDK CMakeLists
#
# Jensen Miller
# Copyright (C) 2019 LooUQ Incorporated.
# Licensed under the GNU license.
#==============================================================================
cmake_minimum_required(VERSION 3.8)
set(PROJECT_NAME "CoreZero-SDK")
set(PROJECT_LIB_NAME "libcorezero")
#
# Project Name Assignment
#
project ("${PROJECT_NAME}")
#
# Configure Directories
#
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# filters
set (EXTERNAL_DEPENDENCIES_FILTER "extern")
set (UNIT_TESTS_FILTER "tests")
#
# Build Options
#
option(BUILD_LIBRARY_AS_SHARED "Build this library as a shared object rather than the default static library." OFF)
option(BUILD_EXAMPLES "Build examples of this library." OFF)
option(BUILD_TESTS "Build the tests of this library" OFF)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(mcu CMAKE_HOST_SYSTEM_PROCESSOR)
endif()
#
# Include all sub-projects
#
# Examples
if (BUILD_EXAMPLES)
add_subdirectory("${PROJECT_SOURCE_DIR}/examples")
endif()
# Tests
if (BUILD_TESTS)
enable_testing()
add_subdirectory("${PROJECT_SOURCE_DIR}/tests")
endif()
#
# Discover all library code
#
file(GLOB_RECURSE LIB_SOURCES FOLLOW_SYMLINKS "${PROJECT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE LIB_INCLUDES FOLLOW_SYMLINKS "${PROJECT_SOURCE_DIR}/include/*.hpp" "${PROJECT_SOURCE_DIR}/include/*.h")
#
# Setup Library by root
#
if (MSVC)
set (CMAKE_CXX_FLAGS "/IGNORE:4996")
endif()
find_library(CoreZero-PDK
NAMES czsystem.lib
HINTS "${PROJECT_SOURCE_DIR}/../CoreZero-PDK"
)
include_directories("${PROJECT_SOURCE_DIR}/../CoreZero-PDK/include")
# Build library as shared or static
if (BUILD_LIBRARY_AS_SHARED)
add_library("${PROJECT_LIB_NAME}" SHARED "")
set_target_properties("${PROJECT_LIB_NAME}" PROPERTIES SUFFIX ".so")
else()
add_library("${PROJECT_LIB_NAME}" STATIC "")
set_target_properties("${PROJECT_LIB_NAME}" PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
# Set include directories
target_include_directories("${PROJECT_LIB_NAME}" PRIVATE "${PROJECT_SOURCE_DIR}/include")
target_sources("${PROJECT_LIB_NAME}" PUBLIC "${LIB_INCLUDES}") # include library headers
target_sources("${PROJECT_LIB_NAME}" PRIVATE "${LIB_SOURCES}") # include library source code