forked from ArgonLang/Argon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (74 loc) · 3.18 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
cmake_minimum_required(VERSION 3.15)
project(Argon VERSION 0.5.2)
set(AR_MAJOR ${PROJECT_VERSION_MAJOR})
set(AR_MINOR ${PROJECT_VERSION_MINOR})
set(AR_PATCH ${PROJECT_VERSION_PATCH})
set(AR_RELEASE_LEVEL "alpha")
set(BASE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
set(BASE_OUTPUT_HEADERS ${BASE_OUTPUT_DIRECTORY}/include/argon)
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
set(BASE_OUTPUT_DIRECTORY "${BASE_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}")
endif ()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BASE_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BASE_OUTPUT_DIRECTORY})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
if (MSVC)
set(CMAKE_CXX_STANDARD 20)
endif ()
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif ()
add_subdirectory(lib/stratum)
add_subdirectory(argon)
add_subdirectory(test EXCLUDE_FROM_ALL)
# *** Argon main executable ***
add_executable(${CMAKE_PROJECT_NAME} "${CMAKE_SOURCE_DIR}/argon/main.cc")
add_dependencies(${CMAKE_PROJECT_NAME} ArgonVM)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ArgonVM)
file(COPY arlib/ DESTINATION ${BASE_OUTPUT_DIRECTORY}/packages)
# *** Install ***
set(PROJECT_NAME_MAJOR_MINOR ${PROJECT_NAME}${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
set(PROJECT_NAME_OUTPUT_LIB "argon${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
# *** Export Argon headers file ***
file(GLOB_RECURSE HEADERS
"${PROJECT_SOURCE_DIR}/argon/*.h"
"${PROJECT_SOURCE_DIR}/argon/*.hpp")
file(MAKE_DIRECTORY ${BASE_OUTPUT_HEADERS})
foreach (header_file ${HEADERS})
file(RELATIVE_PATH rel_header_file ${PROJECT_SOURCE_DIR}/argon ${header_file})
get_filename_component(header_path "${rel_header_file}" DIRECTORY)
file(MAKE_DIRECTORY ${BASE_OUTPUT_HEADERS}/${header_path})
configure_file(${header_file} ${BASE_OUTPUT_HEADERS}/${rel_header_file} COPYONLY)
endforeach ()
install(TARGETS ${CMAKE_PROJECT_NAME} ArgonVM
EXPORT ArgonTargets)
# Install headers
install(DIRECTORY ${BASE_OUTPUT_HEADERS} DESTINATION include)
# Install arlib
install(DIRECTORY ${PROJECT_SOURCE_DIR}/arlib/
DESTINATION "lib/${PROJECT_NAME_OUTPUT_LIB}/packages")
install(EXPORT ArgonTargets
FILE ArgonTargets.cmake
NAMESPACE Argon::
DESTINATION lib/cmake/${PROJECT_NAME_MAJOR_MINOR})
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/ArgonConfig.cmake"
INSTALL_DESTINATION "lib/cmake/${PROJECT_NAME_MAJOR_MINOR}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ArgonConfigVersion.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/ArgonConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ArgonConfigVersion.cmake
DESTINATION lib/cmake/${PROJECT_NAME_MAJOR_MINOR})
# *** Export package ***
set(CMAKE_EXPORT_PACKAGE_REGISTRY ON)
export(TARGETS ArgonVM
NAMESPACE Argon::
FILE "${CMAKE_CURRENT_BINARY_DIR}/ArgonTargets.cmake")
export(PACKAGE Argon)