diff options
author | redfish <redfish@galactica.pw> | 2017-10-20 22:07:34 -0400 |
---|---|---|
committer | redfish <redfish@galactica.pw> | 2017-10-20 22:07:34 -0400 |
commit | 11e0deef31a0361430d3d68f6f90e5c40a956d71 (patch) | |
tree | 5471888b9fbbc4853dddde8c7b2994178895b9a4 /src/CMakeLists.txt | |
parent | .gitignore: do not ignore cmake source files (diff) | |
download | monero-11e0deef31a0361430d3d68f6f90e5c40a956d71.tar.xz |
cmake: add dep of version lib on version.cpp
Also, move cmake source files into cmake/ to keep them together.
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r-- | src/CMakeLists.txt | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6fb08b645..0281b1df6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -83,26 +83,30 @@ function (monero_add_executable name) endfunction () function (monero_add_library name) - source_group("${name}" - FILES - ${ARGN}) + monero_add_library_with_deps(NAME "${name}" SOURCES ${ARGN}) +endfunction() + +function (monero_add_library_with_deps) + cmake_parse_arguments(MONERO_ADD_LIBRARY "" "NAME" "DEPENDS;SOURCES" ${ARGN}) + source_group("${MONERO_ADD_LIBRARY_NAME}" FILES ${MONERO_ADD_LIBRARY_SOURCES}) # Define a ("virtual") object library and an actual library that links those # objects together. The virtual libraries can be arbitrarily combined to link # any subset of objects into one library archive. This is used for releasing # libwallet, which combines multiple components. - set(objlib obj_${name}) - add_library(${objlib} OBJECT ${ARGN}) - add_library("${name}" $<TARGET_OBJECTS:${objlib}>) - set_property(TARGET "${name}" - PROPERTY - FOLDER "libs") + set(objlib obj_${MONERO_ADD_LIBRARY_NAME}) + add_library(${objlib} OBJECT ${MONERO_ADD_LIBRARY_SOURCES}) + add_library("${MONERO_ADD_LIBRARY_NAME}" $<TARGET_OBJECTS:${objlib}>) + if (MONERO_ADD_LIBRARY_DEPENDS) + add_dependencies(${objlib} ${MONERO_ADD_LIBRARY_DEPENDS}) + endif() + set_property(TARGET "${MONERO_ADD_LIBRARY_NAME}" PROPERTY FOLDER "libs") target_compile_definitions(${objlib} - PRIVATE $<TARGET_PROPERTY:${name},INTERFACE_COMPILE_DEFINITIONS>) + PRIVATE $<TARGET_PROPERTY:${MONERO_ADD_LIBRARY_NAME},INTERFACE_COMPILE_DEFINITIONS>) endfunction () -set_source_files_properties(${CMAKE_BINARY_DIR}/version.cpp PROPERTIES GENERATED ON) -monero_add_library(version ${CMAKE_BINARY_DIR}/version.cpp) +include(Version) +monero_add_library(version SOURCES ${CMAKE_BINARY_DIR}/version.cpp DEPENDS genversion) add_subdirectory(common) add_subdirectory(crypto) |