generated from jensen-miller/CMake-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (71 loc) · 2.17 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
#[[
===============================================================================
.NET IoT SDK - C++
Provides a platform abstract layer for the interface between dotnet/iot and
any framework in c++.
Copyright (C) 2019 Jensen Miller.
Licensed under the GNU GPLv3 license.
===============================================================================
]]
cmake_minimum_required (VERSION 3.8)
set(PROJECT_NAME "dotnet-iot-sdk-cpp")
set(PROJECT_LIB_NAME "lib_dotnet_iot_sdk")
#
# Config
#
# Path to cmake modules
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
# Don't allow in-source builds
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "You cannot build in a directory that contains a cmake file.")
endif()
#
# Project Name
#
project ("${PROJECT_NAME}")
#
# Build options
#
option(BUILD_LIBRARY_SHARED "Build the library as a shared object, will build it as a static library otherwise." OFF)
option(BUILD_EXAMPLES "Build the samples." ON)
option(BUILD_TESTS "Build the tests." OFF)
#
# Include sub-projects.
#
# Applications
if (BUILD_APPLICATIONS)
add_subdirectory("${PROJECT_SOURCE_DIR}/applications")
endif()
# Examples
if (BUILD_EXAMPLES)
add_subdirectory ("${PROJECT_SOURCE_DIR}/examples/my-example")
endif()
# Tests
if (BUILD_TESTS)
add_subdirectory(tests)
endif()
#
# Discover all library code
#
file(GLOB_RECURSE SOURCES FOLLOW_SYMLINKS "${PROJECT_SOURCE_DIR}/src/*.cpp")
file(GLOB_RECURSE INCLUDES FOLLOW_SYMLINKS "${PROJECT_SOURCE_DIR}/include/*.hpp")
#
# Setup library by root
#
if (BUILD_LIBRARY_SHARED)
add_library("${PROJECT_LIB_NAME}" STATIC "")
set_target_properties(${SDK_TARGET_NAME} PROPERTIES SUFFIX ".so")
else()
add_library("${PROJECT_LIB_NAME}" STATIC "")
set_target_properties("${PROJECT_LIB_NAME}" PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
target_include_directories("${PROJECT_LIB_NAME}" PRIVATE "${PROJECT_SOURCE_DIR}/include")
target_sources("${PROJECT_LIB_NAME}" PUBLIC "${INCLUDES}") # include library headers
target_sources("${PROJECT_LIB_NAME}" PRIVATE "${SOURCES}") # include library source code
#
# Dependencies
#
#
# Print additional information
#
#add_feature_info()