Skip to content

Commit

Permalink
Improve subproj handling and deprecated target options:
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mellery451 authored and seelabs committed Aug 9, 2018
1 parent 7a547b8 commit dbc8f14
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
15 changes: 11 additions & 4 deletions Builds/CMake/CMakeFuncs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ macro(parse_target)
endif()

if (${cur_component} STREQUAL unity)
set(unity true)
set(unity ON CACHE BOOL "" FORCE)
endif()

if (${cur_component} STREQUAL nounity)
set(unity false)
set(unity OFF CACHE BOOL "" FORCE)
endif()

if (${cur_component} STREQUAL debug)
Expand All @@ -66,12 +66,12 @@ macro(parse_target)
endif()

if (${cur_component} STREQUAL coverage)
set(coverage true)
set(coverage ON CACHE BOOL "" FORCE)
set(debug true)
endif()

if (${cur_component} STREQUAL profile)
set(profile true)
set(profile ON CACHE BOOL "" FORCE)
endif()
endwhile()
endif()
Expand Down Expand Up @@ -108,3 +108,10 @@ macro(group_sources curdir)
group_sources_in(${PROJECT_SOURCE_DIR} ${curdir})
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 ()

18 changes: 14 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ if (is_multiconfig STREQUAL "NOTFOUND")
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
set (is_clang TRUE)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Expand Down Expand Up @@ -655,6 +661,7 @@ add_custom_command (TARGET lz4 POST_BUILD
${CMAKE_BINARY_DIR}/lz4/include
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:lz4> ${CMAKE_BINARY_DIR}/lz4/lib)
exclude_if_included (lz4)

#[===================================================================[
NIH dep: libarchive (via external project)
Expand Down Expand Up @@ -805,6 +812,7 @@ add_custom_command (TARGET sqlite3 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:sqlite3> ${CMAKE_BINARY_DIR}/sqlite3/lib
BYPRODUCTS ${CMAKE_BINARY_DIR}/sqlite3/include/sqlite3.h)
exclude_if_included (sqlite3)

#[===================================================================[
NIH dep: soci
Expand Down Expand Up @@ -840,6 +848,7 @@ target_link_libraries (soci
Ripple::boost)
add_library (NIH::soci ALIAS soci)
target_link_libraries (ripple_libs INTERFACE NIH::soci)
exclude_if_included (soci)

#[===================================================================[
NIH dep: snappy
Expand All @@ -862,6 +871,7 @@ target_include_directories (snappy
src/snappy/config)
add_library (NIH::snappy ALIAS snappy)
target_link_libraries (ripple_libs INTERFACE NIH::snappy)
exclude_if_included (snappy)

#[===================================================================[
NIH dep: rocksdb
Expand Down Expand Up @@ -908,6 +918,7 @@ else ()
endif ()
add_library (NIH::rocksdb ALIAS rocksdb)
target_link_libraries (ripple_libs INTERFACE NIH::rocksdb)
exclude_if_included (rocksdb)

#[===================================================================[
NIH dep: nudb
Expand Down Expand Up @@ -1012,6 +1023,7 @@ target_compile_options (pbufs
>)
add_library (Ripple::pbufs ALIAS pbufs)
target_link_libraries (ripple_libs INTERFACE Ripple::pbufs)
exclude_if_included (pbufs)

#[===================================================================[
xrpl_core
Expand Down Expand Up @@ -2012,6 +2024,7 @@ target_link_libraries (rippled
Ripple::libs
Ripple::boost
Ripple::xrpl_core)
exclude_if_included (rippled)

#[===================================================================[
install stuff
Expand Down Expand Up @@ -2041,7 +2054,7 @@ write_basic_package_version_file (
VERSION ${rippled_version}
COMPATIBILITY SameMajorVersion)

if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
if (is_root_project)
install (TARGETS rippled RUNTIME DESTINATION bin)
set_target_properties(rippled PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
install (
Expand All @@ -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/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 ()

#[===================================================================[
Expand Down

0 comments on commit dbc8f14

Please sign in to comment.