Skip to content

Commit 7f59fe8

Browse files
committed
Add base for cxx port.
1 parent c769cc8 commit 7f59fe8

File tree

8 files changed

+722
-83
lines changed

8 files changed

+722
-83
lines changed

source/ports/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif()
2828

2929
# Project options
3030
option(OPTION_BUILD_PORTS_CS "Build C# port." OFF)
31-
option(OPTION_BUILD_PORTS_CXX "Build C++ port." OFF)
31+
option(OPTION_BUILD_PORTS_CXX "Build C++ port." ON)
3232
option(OPTION_BUILD_PORTS_D "Build D port." OFF)
3333
option(OPTION_BUILD_PORTS_GO "Build Go port." OFF)
3434
option(OPTION_BUILD_PORTS_JAVA "Build Java port." OFF)

source/ports/cxx_port/CMakeLists.txt

Lines changed: 32 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@ endif()
99

1010
# Target name
1111
set(target cxx_port)
12-
string(TOLOWER ${META_PROJECT_NAME} target_name)
13-
14-
set(target_export "${META_PROJECT_NAME}-cxx")
1512

1613
# Exit here if required dependencies are not met
1714
message(STATUS "Port ${target}")
1815

1916
# Set API export file and macro
20-
string(TOUPPER ${target_name} target_name_upper)
21-
set(export_file "include/${target_name}/${target_name}_api.hpp")
22-
set(export_macro "${target_name_upper}_API")
17+
string(TOUPPER ${target} target_upper)
18+
set(export_file "include/${target}/${target}_api.h")
19+
set(export_macro "${target_upper}_API")
2320

2421
#
2522
# Compiler warnings
@@ -37,8 +34,8 @@ include(SecurityFlags)
3734
# Sources
3835
#
3936

40-
set(inline_path "${CMAKE_CURRENT_SOURCE_DIR}/inline/${target_name}")
41-
set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/${target_name}")
37+
set(inline_path "${CMAKE_CURRENT_SOURCE_DIR}/inline/metacall")
38+
set(include_path "${CMAKE_CURRENT_SOURCE_DIR}/include/metacall")
4239
set(source_path "${CMAKE_CURRENT_SOURCE_DIR}/source")
4340

4441
set(inlines
@@ -79,7 +76,7 @@ add_library(${target}
7976
add_library(${META_PROJECT_NAME}::${target} ALIAS ${target})
8077

8178
# Export library for downstream projects
82-
export(TARGETS ${target} NAMESPACE ${META_PROJECT_NAME}:: FILE ${PROJECT_BINARY_DIR}/cmake/${target_name}/${target_export}-export.cmake)
79+
export(TARGETS ${target} NAMESPACE ${META_PROJECT_NAME}:: FILE ${PROJECT_BINARY_DIR}/cmake/${target}/${target}-export.cmake)
8380

8481
# Create API export header
8582
generate_export_header(${target}
@@ -100,12 +97,16 @@ set_target_properties(${target}
10097
#
10198
# Include directories
10299
#
100+
103101
target_include_directories(${target}
104102
PRIVATE
105103
${PROJECT_BINARY_DIR}/source/include
106104
${CMAKE_CURRENT_SOURCE_DIR}/include
107105
${CMAKE_CURRENT_BINARY_DIR}/include
106+
107+
${PROJECT_BINARY_DIR}/source/inline
108108
${CMAKE_CURRENT_SOURCE_DIR}/inline
109+
${CMAKE_CURRENT_BINARY_DIR}/inline
109110

110111
PUBLIC
111112
${DEFAULT_INCLUDE_DIRECTORIES}
@@ -114,6 +115,26 @@ target_include_directories(${target}
114115
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
115116
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
116117
$<INSTALL_INTERFACE:include>
118+
119+
120+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inline>
121+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/inline>
122+
$<INSTALL_INTERFACE:inline>
123+
)
124+
125+
#
126+
# Libraries
127+
#
128+
129+
target_link_libraries(${target}
130+
PRIVATE
131+
${META_PROJECT_NAME}::metacall
132+
133+
PUBLIC
134+
${DEFAULT_LIBRARIES}
135+
136+
INTERFACE
137+
${META_PROJECT_NAME}::metacall
117138
)
118139

119140
#
@@ -122,9 +143,10 @@ target_include_directories(${target}
122143

123144
target_compile_definitions(${target}
124145
PRIVATE
146+
${target_upper}_EXPORTS # Export API
125147

126148
PUBLIC
127-
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:${target_name_upper}_STATIC_DEFINE>
149+
$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:${target_upper}_STATIC_DEFINE>
128150
${DEFAULT_COMPILE_DEFINITIONS}
129151

130152
INTERFACE
@@ -155,72 +177,3 @@ target_link_options(${target}
155177

156178
INTERFACE
157179
)
158-
159-
#
160-
# Deployment
161-
#
162-
163-
# Library
164-
install(TARGETS ${target}
165-
EXPORT "${target_export}-export" COMPONENT dev
166-
RUNTIME DESTINATION ${INSTALL_BIN} COMPONENT runtime
167-
LIBRARY DESTINATION ${INSTALL_SHARED} COMPONENT runtime
168-
ARCHIVE DESTINATION ${INSTALL_LIB} COMPONENT dev
169-
)
170-
171-
# Inline files
172-
install(DIRECTORY
173-
${CMAKE_CURRENT_SOURCE_DIR}/inline/${target_name} DESTINATION ${INSTALL_INCLUDE}
174-
COMPONENT dev
175-
)
176-
177-
# Header files
178-
install(DIRECTORY
179-
${CMAKE_CURRENT_SOURCE_DIR}/include/${target_name} DESTINATION ${INSTALL_INCLUDE}
180-
COMPONENT dev
181-
)
182-
183-
# Generated header files
184-
install(DIRECTORY
185-
${CMAKE_CURRENT_BINARY_DIR}/include/${target_name} DESTINATION ${INSTALL_INCLUDE}
186-
COMPONENT dev
187-
)
188-
189-
# CMake config
190-
install(EXPORT ${target_export}-export
191-
NAMESPACE ${META_PROJECT_NAME}::
192-
DESTINATION ${INSTALL_CMAKE}/${target_name}
193-
COMPONENT dev
194-
)
195-
196-
# TODO
197-
198-
# #
199-
# # Configure test
200-
# #
201-
202-
# set(metacall_cxx_test "${target}_test")
203-
# set(metacall_cxx_test_path "${CMAKE_CURRENT_BINARY_DIR}/${metacall_cxx_test}.cpp")
204-
205-
# #
206-
# # Define test
207-
# #
208-
209-
# add_test(NAME ${metacall_cxx_test}
210-
# COMMAND $<TARGET_FILE:${metacall_cxx_test}>
211-
# )
212-
213-
# #
214-
# # Define test labels
215-
# #
216-
217-
# set_property(TEST ${metacall_cxx_test}
218-
# PROPERTY LABELS ${metacall_cxx_test}
219-
# )
220-
221-
# include(TestEnvironmentVariables)
222-
223-
# test_environment_variables(${metacall_cxx_test}
224-
# ""
225-
# ${TESTS_ENVIRONMENT_VARIABLES}
226-
# )

0 commit comments

Comments
 (0)