-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
119 lines (102 loc) · 3.19 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
cmake_minimum_required(VERSION 3.23)
project(
milo
VERSION 0.2.0
LANGUAGES CXX
)
include(CheckLanguage)
include(GNUInstallDirs)
# Testing options.
option(MILO_TEST "Enable testing." OFF)
option(MILO_TEST_CONSTEXPR "Enable constexpr testing." OFF)
option(MILO_TEST_INTERNAL "Enable internal testing." OFF)
option(MILO_TEST_PRIMITIVE "Enable primitive testing." OFF)
# Assembly options.
option(MILO_ASM "Enable assembly." ON)
# Application options.
option(MILO_APP "Enable application." OFF)
add_library(
${PROJECT_NAME}
STATIC
)
# Resolve sources.
set(MILO_HDR_FILES "")
set(MILO_SRC_FILES "")
set(MILO_ASM_FILES "")
set(MILO_ASM_FOUND FALSE)
file(GLOB_RECURSE MILO_HDR_FILES CONFIGURE_DEPENDS src/*.h)
file(GLOB_RECURSE MILO_SRC_FILES CONFIGURE_DEPENDS src/*.cpp)
if (${MILO_ASM})
if (
${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64" OR
${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64"
)
check_language(ASM_NASM)
if (CMAKE_ASM_NASM_COMPILER)
enable_language(ASM_NASM)
set(MILO_ASM_FOUND TRUE)
set(CMAKE_ASM_NASM_FLAGS "-i ${PROJECT_SOURCE_DIR}/src/milo/internal/arch/x86_64")
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} --gprefix _")
endif()
file(
GLOB_RECURSE MILO_ASM_FILES
CONFIGURE_DEPENDS
src/milo/internal/arch/x86_64/*.asm
src/*x86_64.asm
)
message(STATUS "[${PROJECT_NAME}] Assembler for the current target was found, NASM is available")
else ()
message(STATUS "[${PROJECT_NAME}] Assembler for the current target was not found, NASM is missing")
endif ()
else ()
message(STATUS "[${PROJECT_NAME}] Assembler for the current target is not used")
endif ()
if (${MILO_ASM_FOUND})
message(STATUS "[${PROJECT_NAME}] Assembler configuration done")
else ()
message(STATUS "[${PROJECT_NAME}] Assembler configuration skipped")
endif ()
endif ()
target_include_directories(
${PROJECT_NAME}
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
)
target_sources(
${PROJECT_NAME}
PUBLIC
FILE_SET HEADERS BASE_DIRS src FILES ${MILO_HDR_FILES}
PRIVATE
${MILO_SRC_FILES}
${MILO_ASM_FILES}
)
target_compile_definitions(
${PROJECT_NAME}
PUBLIC
$<$<BOOL:${MILO_ASM_FOUND}>:MILO_INTERNAL_ASM=true>
$<$<IN_LIST:$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>,linux;darwin>:MILO_INTERNAL_ABI_UNIX=true>
$<$<IN_LIST:$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>,windows>:MILO_INTERNAL_ABI_WIND=true>
)
target_compile_features(
${PROJECT_NAME}
PUBLIC
cxx_std_20
)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-config
FILE_SET HEADERS
)
install(
EXPORT ${PROJECT_NAME}-config
DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake
)
if (${MILO_TEST})
enable_testing()
add_subdirectory(test)
endif ()
if (${MILO_APP})
add_subdirectory(app)
endif ()