2018-05-04 07:28:18 +08:00
|
|
|
set(FDB_C_SRCS
|
|
|
|
fdb_c.cpp
|
|
|
|
foundationdb/fdb_c.h
|
|
|
|
ThreadCleanup.cpp)
|
|
|
|
|
|
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/foundationdb)
|
|
|
|
|
2019-02-06 11:29:01 +08:00
|
|
|
set(asm_file ${CMAKE_CURRENT_BINARY_DIR}/fdb_c.g.S)
|
|
|
|
|
|
|
|
set(platform "linux")
|
2018-05-04 07:28:18 +08:00
|
|
|
if(APPLE)
|
|
|
|
set(platform "osx")
|
2019-02-06 11:29:01 +08:00
|
|
|
elseif(WIN32)
|
|
|
|
set(platform "windows")
|
|
|
|
set(asm_file ${CMAKE_CURRENT_BINARY_DIR}/fdb_c.g.asm)
|
2018-05-04 07:28:18 +08:00
|
|
|
endif()
|
|
|
|
|
2019-02-06 11:29:01 +08:00
|
|
|
add_custom_command(OUTPUT ${asm_file} ${CMAKE_CURRENT_BINARY_DIR}/fdb_c_function_pointers.g.h
|
2019-02-11 13:14:14 +08:00
|
|
|
COMMAND $<TARGET_FILE:Python::Interpreter> ${CMAKE_CURRENT_SOURCE_DIR}/generate_asm.py ${platform}
|
2018-05-04 07:28:18 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/fdb_c.cpp
|
2019-02-06 11:29:01 +08:00
|
|
|
${asm_file}
|
2018-05-04 07:28:18 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/fdb_c_function_pointers.g.h
|
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate_asm.py ${CMAKE_CURRENT_SOURCE_DIR}/fdb_c.cpp
|
|
|
|
COMMENT "Generate C bindings")
|
2019-02-06 11:29:01 +08:00
|
|
|
add_custom_target(fdb_c_generated DEPENDS ${asm_file}
|
2018-05-04 07:28:18 +08:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/fdb_c_function_pointers.g.h)
|
|
|
|
|
2019-02-05 13:25:10 +08:00
|
|
|
vexillographer_compile(TARGET fdb_c_options LANG c OUT ${CMAKE_CURRENT_BINARY_DIR}/foundationdb/fdb_c_options.g.h
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foundationdb/fdb_c_options.g.h)
|
2018-05-04 07:28:18 +08:00
|
|
|
|
2018-05-05 06:35:27 +08:00
|
|
|
include(GenerateExportHeader)
|
|
|
|
|
2019-02-18 09:54:54 +08:00
|
|
|
if(OPEN_FOR_IDE)
|
|
|
|
add_library(fdb_c OBJECT ${FDB_C_SRCS} ${asm_file})
|
|
|
|
else()
|
|
|
|
add_library(fdb_c SHARED ${FDB_C_SRCS} ${asm_file})
|
2019-03-21 11:27:10 +08:00
|
|
|
strip_debug_symbols(fdb_c)
|
2019-02-18 09:54:54 +08:00
|
|
|
endif()
|
2018-05-04 07:28:18 +08:00
|
|
|
add_dependencies(fdb_c fdb_c_generated fdb_c_options)
|
|
|
|
target_link_libraries(fdb_c PUBLIC fdbclient)
|
2018-05-05 06:35:27 +08:00
|
|
|
target_include_directories(fdb_c PUBLIC
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/foundationdb)
|
2019-02-06 11:29:01 +08:00
|
|
|
if(WIN32)
|
|
|
|
enable_language(ASM_MASM)
|
|
|
|
set_property(SOURCE ${asm_file} PROPERTY LANGUAGE ASM_MASM)
|
|
|
|
endif()
|
2019-02-10 07:13:25 +08:00
|
|
|
|
2019-02-11 13:29:03 +08:00
|
|
|
# The tests don't build on windows
|
|
|
|
if(NOT WIN32)
|
2019-06-07 07:58:11 +08:00
|
|
|
set(MAKO_SRCS
|
|
|
|
test/mako/mako.c
|
|
|
|
test/mako/mako.h
|
|
|
|
test/mako/utils.c
|
|
|
|
test/mako/utils.h
|
|
|
|
test/mako/zipf.c
|
|
|
|
test/mako/zipf.h)
|
|
|
|
|
2019-02-18 11:29:33 +08:00
|
|
|
if(OPEN_FOR_IDE)
|
|
|
|
add_library(fdb_c_performance_test OBJECT test/performance_test.c test/test.h)
|
|
|
|
add_library(fdb_c_ryw_benchmark OBJECT test/ryw_benchmark.c test/test.h)
|
2019-06-07 07:58:11 +08:00
|
|
|
add_library(mako OBJECT ${MAKO_SRCS})
|
2019-02-18 11:29:33 +08:00
|
|
|
else()
|
|
|
|
add_executable(fdb_c_performance_test test/performance_test.c test/test.h)
|
|
|
|
add_executable(fdb_c_ryw_benchmark test/ryw_benchmark.c test/test.h)
|
2019-06-07 07:58:11 +08:00
|
|
|
add_executable(mako ${MAKO_SRCS})
|
2019-03-21 11:27:10 +08:00
|
|
|
strip_debug_symbols(fdb_c_performance_test)
|
|
|
|
strip_debug_symbols(fdb_c_ryw_benchmark)
|
2019-02-18 11:29:33 +08:00
|
|
|
endif()
|
2019-02-11 13:29:03 +08:00
|
|
|
target_link_libraries(fdb_c_performance_test PRIVATE fdb_c)
|
|
|
|
target_link_libraries(fdb_c_ryw_benchmark PRIVATE fdb_c)
|
2019-06-07 05:53:26 +08:00
|
|
|
# do not set RPATH for mako
|
|
|
|
set_property(TARGET mako PROPERTY SKIP_BUILD_RPATH TRUE)
|
2019-06-05 08:35:47 +08:00
|
|
|
target_link_libraries(mako PRIVATE fdb_c)
|
2019-02-11 13:29:03 +08:00
|
|
|
endif()
|
2019-02-10 07:13:25 +08:00
|
|
|
|
2019-02-28 12:17:11 +08:00
|
|
|
# TODO: re-enable once the old vcxproj-based build system is removed.
|
|
|
|
#generate_export_header(fdb_c EXPORT_MACRO_NAME "DLLEXPORT"
|
|
|
|
# EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/foundationdb/fdb_c_export.h)
|
|
|
|
fdb_install(TARGETS fdb_c
|
|
|
|
DESTINATION lib
|
|
|
|
COMPONENT clients)
|
|
|
|
fdb_install(
|
|
|
|
FILES foundationdb/fdb_c.h
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/foundationdb/fdb_c_options.g.h
|
|
|
|
${CMAKE_SOURCE_DIR}/fdbclient/vexillographer/fdb.options
|
|
|
|
DESTINATION include COMPONENT clients)
|
|
|
|
#install(EXPORT fdbc DESTINATION ${FDB_LIB_DIR}/foundationdb COMPONENT clients)
|