From 815bdb2fb5751cf59daf576a4d6c5a3882a4173f Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 29 Dec 2021 01:51:27 +0400 Subject: [PATCH] Specify submodule path as URL rather than SOURCE_DIR to ExternalProject --- external/dispatch/CMakeLists.txt | 7 ++-- external/jemalloc/CMakeLists.txt | 67 ++++++++++++++++---------------- external/kwayland/CMakeLists.txt | 8 ++-- 3 files changed, 42 insertions(+), 40 deletions(-) diff --git a/external/dispatch/CMakeLists.txt b/external/dispatch/CMakeLists.txt index cc18c2a..e89aace 100644 --- a/external/dispatch/CMakeLists.txt +++ b/external/dispatch/CMakeLists.txt @@ -19,11 +19,10 @@ if (DESKTOP_APP_USE_PACKAGED) endif() add_library(external_dispatch_bundled STATIC IMPORTED) -set(dispatch_loc ${third_party_loc}/dispatch) include(ExternalProject) ExternalProject_Add(dispatch - SOURCE_DIR ${dispatch_loc} + URL ${third_party_loc}/dispatch CMAKE_GENERATOR Ninja CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release @@ -38,14 +37,16 @@ ExternalProject_Add(dispatch /src/BlocksRuntime/libBlocksRuntime.a ) +ExternalProject_Get_property(dispatch SOURCE_DIR) ExternalProject_Get_property(dispatch BINARY_DIR) + set_target_properties(external_dispatch_bundled PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/src/libdispatch.a" ) target_include_directories(external_dispatch_bundled SYSTEM INTERFACE - ${dispatch_loc} + ${SOURCE_DIR} ) target_link_libraries(external_dispatch_bundled diff --git a/external/jemalloc/CMakeLists.txt b/external/jemalloc/CMakeLists.txt index 713aad0..13227f5 100644 --- a/external/jemalloc/CMakeLists.txt +++ b/external/jemalloc/CMakeLists.txt @@ -23,47 +23,46 @@ if (DESKTOP_APP_USE_PACKAGED) ${JEMALLOC_LINK_LIBRARIES} -Wl,--as-needed ) + return() endif() endif() -if (NOT JEMALLOC_FOUND) - add_library(external_jemalloc_bundled STATIC IMPORTED) - set(jemalloc_loc ${third_party_loc}/jemalloc) +add_library(external_jemalloc_bundled STATIC IMPORTED) - include(ExternalProject) - ExternalProject_Add(jemalloc - SOURCE_DIR ${jemalloc_loc} - CONFIGURE_COMMAND cd "${jemalloc_loc}" && export EXTRA_CFLAGS=-fstack-protector-all\ -fPIC\ -D_FORTIFY_SOURCE=2 && export EXTRA_CXXFLAGS=-fstack-protector-all\ -fPIC\ -D_FORTIFY_SOURCE=2 && CC=clang CXX=clang++ ./autogen.sh - BUILD_IN_SOURCE 1 - STEP_TARGETS build - EXCLUDE_FROM_ALL TRUE - BUILD_BYPRODUCTS ${jemalloc_loc}/lib/libjemalloc.a - ) +include(ExternalProject) +ExternalProject_Add(jemalloc + URL ${third_party_loc}/jemalloc + CONFIGURE_COMMAND cd "" && export EXTRA_CFLAGS=-fstack-protector-all\ -fPIC\ -D_FORTIFY_SOURCE=2 && export EXTRA_CXXFLAGS=-fstack-protector-all\ -fPIC\ -D_FORTIFY_SOURCE=2 && CC=clang CXX=clang++ ./autogen.sh + BUILD_IN_SOURCE 1 + STEP_TARGETS build + EXCLUDE_FROM_ALL TRUE + BUILD_BYPRODUCTS /lib/libjemalloc.a +) - file(MAKE_DIRECTORY "${jemalloc_loc}/include") +ExternalProject_Get_property(jemalloc SOURCE_DIR) +file(MAKE_DIRECTORY "${SOURCE_DIR}/include") - set_target_properties(external_jemalloc_bundled PROPERTIES - IMPORTED_LOCATION "${jemalloc_loc}/lib/libjemalloc.a" - ) +set_target_properties(external_jemalloc_bundled PROPERTIES + IMPORTED_LOCATION "${SOURCE_DIR}/lib/libjemalloc.a" +) - target_include_directories(external_jemalloc_bundled SYSTEM - INTERFACE - ${jemalloc_loc}/include - ) +target_include_directories(external_jemalloc_bundled SYSTEM +INTERFACE + ${SOURCE_DIR}/include +) - target_link_libraries(external_jemalloc_bundled - INTERFACE - ${CMAKE_DL_LIBS} - pthread - ) +target_link_libraries(external_jemalloc_bundled +INTERFACE + ${CMAKE_DL_LIBS} + pthread +) - add_dependencies(external_jemalloc_bundled jemalloc-build) +add_dependencies(external_jemalloc_bundled jemalloc-build) - target_link_libraries(external_jemalloc - INTERFACE - -Wl,--whole-archive - $ - -Wl,--no-whole-archive - external_jemalloc_bundled - ) -endif() +target_link_libraries(external_jemalloc +INTERFACE + -Wl,--whole-archive + $ + -Wl,--no-whole-archive + external_jemalloc_bundled +) diff --git a/external/kwayland/CMakeLists.txt b/external/kwayland/CMakeLists.txt index 5260d82..397338a 100644 --- a/external/kwayland/CMakeLists.txt +++ b/external/kwayland/CMakeLists.txt @@ -17,7 +17,6 @@ if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_QT6) endif() add_library(external_kwayland_bundled STATIC IMPORTED) -set(kwayland_loc ${third_party_loc}/kwayland) set(kwayland_patch_command :) if (DESKTOP_APP_QT6) @@ -26,7 +25,7 @@ endif() include(ExternalProject) ExternalProject_Add(kwayland - SOURCE_DIR ${kwayland_loc} + URL ${third_party_loc}/kwayland CMAKE_GENERATOR Ninja CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release @@ -39,7 +38,10 @@ ExternalProject_Add(kwayland BUILD_BYPRODUCTS /lib/libKF5WaylandClient.a ) +ExternalProject_Get_property(kwayland SOURCE_DIR) ExternalProject_Get_property(kwayland BINARY_DIR) + +file(MAKE_DIRECTORY "${SOURCE_DIR}/src/client") file(MAKE_DIRECTORY "${BINARY_DIR}/src/client") set_target_properties(external_kwayland_bundled PROPERTIES @@ -48,7 +50,7 @@ set_target_properties(external_kwayland_bundled PROPERTIES target_include_directories(external_kwayland_bundled SYSTEM INTERFACE - ${kwayland_loc}/src/client + ${SOURCE_DIR}/src/client ${BINARY_DIR}/src/client )