-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
88 lines (69 loc) · 1.97 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
cmake_minimum_required(VERSION 3.15)
# ==================================================
# Project
project(
AyTiny
VERSION 0.1.0
LANGUAGES CXX
)
# Module: namespace::name
set(MODULE_NAME aytiny)
set(MODULE_NS ayin)
string(TOUPPER "${MODULE_NAME}" MODULE_NAME_UPPER)
# ==================================================
include(GenerateExportHeader)
# Project options
include(cmake/Options.cmake)
# Utils
include(cmake/Utils.cmake)
# Init cmake environment
include(cmake/Init.cmake)
# Third party
#add_subdirectory(third_party)
# ==================================================
# Module library
if(${PROJECT_NAME}_BUILD_SHARED)
set(${MODULE_NAME}_LIB_TYPE SHARED)
else()
set(${MODULE_NAME}_LIB_TYPE STATIC)
endif()
file(GLOB_RECURSE ${MODULE_NAME}_HEADERS
CONFIGURE_DEPENDS
"include/*.h" "include/*.hpp"
"include/*.inl" "include/*.tcc"
)
file(GLOB_RECURSE ${MODULE_NAME}_SOURCES
CONFIGURE_DEPENDS
"src/*.cc" "src/*.cpp" "src/*.c"
"src/*.h" "src/*.hpp"
"src/*.inl" "src/*.tcc"
)
add_library(
${MODULE_NAME}
${${MODULE_NAME}_LIB_TYPE}
${${MODULE_NAME}_HEADERS}
${${MODULE_NAME}_SOURCES}
)
if(NOT ${PROJECT_NAME}_BUILD_SHARED)
target_compile_definitions(${MODULE_NAME} PUBLIC ${MODULE_NAME_UPPER}_STATIC_DEFINE)
endif()
generate_export_header(
${MODULE_NAME}
BASE_NAME ${MODULE_NAME}
EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/ext_include/${MODULE_NAME}/export.h"
STATIC_DEFINE "${MODULE_NAME_UPPER}_STATIC_DEFINE"
)
target_include_directories(
${MODULE_NAME}
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
PUBLIC ${CMAKE_BINARY_DIR}/ext_include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
)
add_library(${MODULE_NS}::${MODULE_NAME} ALIAS ${MODULE_NAME})
message(STATUS "Build `${${MODULE_NAME}_LIB_TYPE}` library `${MODULE_NS}::${MODULE_NAME}`")
# ==================================================
# Project development environment
if(${PROJECT_NAME}_IS_MAIN)
# Main
add_subdirectory(main)
endif()