build: cmake: build release.cc as a library
so we can attach compiling definitions in a simpler way. this change is based on Botond Dénes's change which gives an overhaul to the existing CMake building system. Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
@@ -229,7 +229,6 @@ set(scylla_sources
|
||||
redis/command_factory.cc
|
||||
redis/commands.cc
|
||||
redis/lolwut.cc
|
||||
release.cc
|
||||
repair/repair.cc
|
||||
repair/row_level.cc
|
||||
replica/database.cc
|
||||
@@ -322,7 +321,9 @@ add_subdirectory(sstables)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(types)
|
||||
add_subdirectory(utils)
|
||||
|
||||
include(add_version_library)
|
||||
add_version_library(scylla_version
|
||||
release.cc)
|
||||
add_executable(scylla
|
||||
${scylla_sources}
|
||||
${scylla_gen_sources})
|
||||
@@ -334,6 +335,7 @@ target_link_libraries(scylla PRIVATE
|
||||
cql3
|
||||
idl
|
||||
schema
|
||||
scylla_version
|
||||
sstables
|
||||
test-perf
|
||||
types
|
||||
@@ -397,23 +399,6 @@ target_include_directories(scylla PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
"${scylla_gen_build_dir}")
|
||||
|
||||
###
|
||||
### Generate version file and supply appropriate compile definitions for release.cc
|
||||
###
|
||||
execute_process(COMMAND ${CMAKE_SOURCE_DIR}/SCYLLA-VERSION-GEN --output-dir "${CMAKE_BINARY_DIR}/gen" RESULT_VARIABLE scylla_version_gen_res)
|
||||
if(scylla_version_gen_res)
|
||||
message(SEND_ERROR "Version file generation failed. Return code: ${scylla_version_gen_res}")
|
||||
endif()
|
||||
|
||||
file(READ "${CMAKE_BINARY_DIR}/gen/SCYLLA-VERSION-FILE" scylla_version)
|
||||
string(STRIP "${scylla_version}" scylla_version)
|
||||
|
||||
file(READ "${CMAKE_BINARY_DIR}/gen/SCYLLA-RELEASE-FILE" scylla_release)
|
||||
string(STRIP "${scylla_release}" scylla_release)
|
||||
|
||||
get_property(release_cdefs SOURCE "${CMAKE_SOURCE_DIR}/release.cc" PROPERTY COMPILE_DEFINITIONS)
|
||||
list(APPEND release_cdefs "SCYLLA_VERSION=\"${scylla_version}\"" "SCYLLA_RELEASE=\"${scylla_release}\"")
|
||||
set_source_files_properties("${CMAKE_SOURCE_DIR}/release.cc" PROPERTIES COMPILE_DEFINITIONS "${release_cdefs}")
|
||||
|
||||
# TODO: create cmake/ directory and move utilities (generate functions etc) there
|
||||
# TODO: Build tests if BUILD_TESTING=on (using CTest module)
|
||||
|
||||
21
cmake/add_version_library.cmake
Normal file
21
cmake/add_version_library.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
###
|
||||
### Generate version file and supply appropriate compile definitions for release.cc
|
||||
###
|
||||
function(add_version_library name source)
|
||||
set(version_file ${CMAKE_CURRENT_BINARY_DIR}/SCYLLA-VERSION-FILE)
|
||||
set(release_file ${CMAKE_CURRENT_BINARY_DIR}/SCYLLA-RELEASE-FILE)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/SCYLLA-VERSION-GEN --output-dir "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
file(STRINGS ${version_file} scylla_version)
|
||||
file(STRINGS ${release_file} scylla_release)
|
||||
|
||||
add_library(${name} OBJECT ${source})
|
||||
target_compile_definitions(${name}
|
||||
PRIVATE
|
||||
SCYLLA_VERSION=\"${scylla_version}\"
|
||||
SCYLLA_RELEASE=\"${scylla_release}\")
|
||||
target_link_libraries(${name}
|
||||
PRIVATE
|
||||
Seastar::seastar)
|
||||
endfunction(add_version_library)
|
||||
Reference in New Issue
Block a user