Improve subproj handling and deprecated target options:

Exclude several libraries from build when we are included in a
super-project (this is the case when someone only wants to use
xrpl_core). Force several target (deprecated) params to be cache
variables since they are now exposed as options.
This commit is contained in:
Mike Ellery
2018-08-01 16:46:35 -07:00
committed by seelabs
parent 7a547b8cf2
commit dbc8f147c9
2 changed files with 25 additions and 8 deletions

View File

@@ -50,11 +50,11 @@ macro(parse_target)
endif() endif()
if (${cur_component} STREQUAL unity) if (${cur_component} STREQUAL unity)
set(unity true) set(unity ON CACHE BOOL "" FORCE)
endif() endif()
if (${cur_component} STREQUAL nounity) if (${cur_component} STREQUAL nounity)
set(unity false) set(unity OFF CACHE BOOL "" FORCE)
endif() endif()
if (${cur_component} STREQUAL debug) if (${cur_component} STREQUAL debug)
@@ -66,12 +66,12 @@ macro(parse_target)
endif() endif()
if (${cur_component} STREQUAL coverage) if (${cur_component} STREQUAL coverage)
set(coverage true) set(coverage ON CACHE BOOL "" FORCE)
set(debug true) set(debug true)
endif() endif()
if (${cur_component} STREQUAL profile) if (${cur_component} STREQUAL profile)
set(profile true) set(profile ON CACHE BOOL "" FORCE)
endif() endif()
endwhile() endwhile()
endif() endif()
@@ -108,3 +108,10 @@ macro(group_sources curdir)
group_sources_in(${PROJECT_SOURCE_DIR} ${curdir}) group_sources_in(${PROJECT_SOURCE_DIR} ${curdir})
endmacro() endmacro()
macro (exclude_if_included target_)
if (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
set_target_properties (${target_} PROPERTIES EXCLUDE_FROM_ALL ON)
set_target_properties (${target_} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON)
endif ()
endmacro ()

View File

@@ -22,6 +22,12 @@ if (is_multiconfig STREQUAL "NOTFOUND")
endif () endif ()
endif () endif ()
if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
set (is_root_project ON)
else ()
set (is_root_project OFF)
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang") # both Clang and AppleClang if ("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang") # both Clang and AppleClang
set (is_clang TRUE) set (is_clang TRUE)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
@@ -655,6 +661,7 @@ add_custom_command (TARGET lz4 POST_BUILD
${CMAKE_BINARY_DIR}/lz4/include ${CMAKE_BINARY_DIR}/lz4/include
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:lz4> ${CMAKE_BINARY_DIR}/lz4/lib) $<TARGET_FILE:lz4> ${CMAKE_BINARY_DIR}/lz4/lib)
exclude_if_included (lz4)
#[===================================================================[ #[===================================================================[
NIH dep: libarchive (via external project) NIH dep: libarchive (via external project)
@@ -805,6 +812,7 @@ add_custom_command (TARGET sqlite3 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:sqlite3> ${CMAKE_BINARY_DIR}/sqlite3/lib $<TARGET_FILE:sqlite3> ${CMAKE_BINARY_DIR}/sqlite3/lib
BYPRODUCTS ${CMAKE_BINARY_DIR}/sqlite3/include/sqlite3.h) BYPRODUCTS ${CMAKE_BINARY_DIR}/sqlite3/include/sqlite3.h)
exclude_if_included (sqlite3)
#[===================================================================[ #[===================================================================[
NIH dep: soci NIH dep: soci
@@ -840,6 +848,7 @@ target_link_libraries (soci
Ripple::boost) Ripple::boost)
add_library (NIH::soci ALIAS soci) add_library (NIH::soci ALIAS soci)
target_link_libraries (ripple_libs INTERFACE NIH::soci) target_link_libraries (ripple_libs INTERFACE NIH::soci)
exclude_if_included (soci)
#[===================================================================[ #[===================================================================[
NIH dep: snappy NIH dep: snappy
@@ -862,6 +871,7 @@ target_include_directories (snappy
src/snappy/config) src/snappy/config)
add_library (NIH::snappy ALIAS snappy) add_library (NIH::snappy ALIAS snappy)
target_link_libraries (ripple_libs INTERFACE NIH::snappy) target_link_libraries (ripple_libs INTERFACE NIH::snappy)
exclude_if_included (snappy)
#[===================================================================[ #[===================================================================[
NIH dep: rocksdb NIH dep: rocksdb
@@ -908,6 +918,7 @@ else ()
endif () endif ()
add_library (NIH::rocksdb ALIAS rocksdb) add_library (NIH::rocksdb ALIAS rocksdb)
target_link_libraries (ripple_libs INTERFACE NIH::rocksdb) target_link_libraries (ripple_libs INTERFACE NIH::rocksdb)
exclude_if_included (rocksdb)
#[===================================================================[ #[===================================================================[
NIH dep: nudb NIH dep: nudb
@@ -1012,6 +1023,7 @@ target_compile_options (pbufs
>) >)
add_library (Ripple::pbufs ALIAS pbufs) add_library (Ripple::pbufs ALIAS pbufs)
target_link_libraries (ripple_libs INTERFACE Ripple::pbufs) target_link_libraries (ripple_libs INTERFACE Ripple::pbufs)
exclude_if_included (pbufs)
#[===================================================================[ #[===================================================================[
xrpl_core xrpl_core
@@ -2012,6 +2024,7 @@ target_link_libraries (rippled
Ripple::libs Ripple::libs
Ripple::boost Ripple::boost
Ripple::xrpl_core) Ripple::xrpl_core)
exclude_if_included (rippled)
#[===================================================================[ #[===================================================================[
install stuff install stuff
@@ -2041,7 +2054,7 @@ write_basic_package_version_file (
VERSION ${rippled_version} VERSION ${rippled_version}
COMPATIBILITY SameMajorVersion) COMPATIBILITY SameMajorVersion)
if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR}) if (is_root_project)
install (TARGETS rippled RUNTIME DESTINATION bin) install (TARGETS rippled RUNTIME DESTINATION bin)
set_target_properties(rippled PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON) set_target_properties(rippled PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
install ( install (
@@ -2063,9 +2076,6 @@ if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
copy_if_not_exists(\"${CMAKE_CURRENT_SOURCE_DIR}/cfg/rippled-example.cfg\" etc rippled.cfg) copy_if_not_exists(\"${CMAKE_CURRENT_SOURCE_DIR}/cfg/rippled-example.cfg\" etc rippled.cfg)
copy_if_not_exists(\"${CMAKE_CURRENT_SOURCE_DIR}/cfg/validators-example.txt\" etc validators.txt) copy_if_not_exists(\"${CMAKE_CURRENT_SOURCE_DIR}/cfg/validators-example.txt\" etc validators.txt)
") ")
else ()
set_target_properties (rippled PROPERTIES EXCLUDE_FROM_ALL ON)
set_target_properties (rippled PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON)
endif () endif ()
#[===================================================================[ #[===================================================================[