diff options
author | fuzzard <fuzzard@users.noreply.github.com> | 2023-11-05 15:21:42 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-05 15:21:42 +1000 |
commit | 757bd86acc632add94dd5a5ac169a99d62c5bcdd (patch) | |
tree | 6c22258936f342ada464d4595b5b6d34d1ede3c1 /cmake | |
parent | e5490023e0046c6bd4dd5c849106cde5152e33dc (diff) | |
parent | c3c9972ae01ac167de7f9f7cc40b12943ce2755e (diff) |
Merge pull request #21585 from fuzzard/cmake_libcec
[Cmake] enable_internal_cec
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/FindCEC.cmake | 168 | ||||
-rw-r--r-- | cmake/modules/FindFmt.cmake | 14 | ||||
-rw-r--r-- | cmake/modules/FindP8Platform.cmake | 113 | ||||
-rw-r--r-- | cmake/platform/android/android.cmake | 1 | ||||
-rw-r--r-- | cmake/platform/darwin_embedded/ios.cmake | 1 | ||||
-rw-r--r-- | cmake/platform/darwin_embedded/tvos.cmake | 2 | ||||
-rw-r--r-- | cmake/platform/linux/webos.cmake | 1 | ||||
-rw-r--r-- | cmake/platform/windowsstore/windowsstore.cmake | 1 | ||||
-rw-r--r-- | cmake/scripts/common/Macros.cmake | 25 | ||||
-rw-r--r-- | cmake/scripts/common/ModuleHelpers.cmake | 15 |
10 files changed, 302 insertions, 39 deletions
diff --git a/cmake/modules/FindCEC.cmake b/cmake/modules/FindCEC.cmake index b3874ff883..51b6cbb972 100644 --- a/cmake/modules/FindCEC.cmake +++ b/cmake/modules/FindCEC.cmake @@ -8,30 +8,116 @@ # CEC::CEC - The libCEC library if(NOT TARGET CEC::CEC) - find_package(PkgConfig) - if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_CEC libcec QUIET) - endif() + include(cmake/scripts/common/ModuleHelpers.cmake) + + macro(buildCEC) + set(CEC_VERSION ${${MODULE}_VER}) + + set(patches "${CORE_SOURCE_DIR}/tools/depends/target/${MODULE_LC}/001-all-cmakelists.patch" + "${CORE_SOURCE_DIR}/tools/depends/target/${MODULE_LC}/002-all-libceccmakelists.patch" + "${CORE_SOURCE_DIR}/tools/depends/target/${MODULE_LC}/003-all-remove_git_info.patch" + "${CORE_SOURCE_DIR}/tools/depends/target/${MODULE_LC}/004-win-remove_32bit_timet.patch" + "${CORE_SOURCE_DIR}/tools/depends/target/${MODULE_LC}/005-win-pdbstatic.patch") + + generate_patchcommand("${patches}") + + set(CMAKE_ARGS -DBUILD_SHARED_LIBS=ON + -DSKIP_PYTHON_WRAPPER=ON + -DCMAKE_PLATFORM_NO_VERSIONED_SONAME=ON) - find_path(CEC_INCLUDE_DIR NAMES libcec/cec.h libCEC/CEC.h - PATHS ${PC_CEC_INCLUDEDIR} - NO_CACHE) + if(WIN32 AND ARCH STREQUAL "x64") + # Disable _USE_32BIT_TIME_T for x64 win target + list(APPEND CMAKE_ARGS -DWIN64=ON) + endif() - if(PC_CEC_VERSION) - set(CEC_VERSION ${PC_CEC_VERSION}) - elseif(CEC_INCLUDE_DIR AND EXISTS "${CEC_INCLUDE_DIR}/libcec/version.h") - file(STRINGS "${CEC_INCLUDE_DIR}/libcec/version.h" cec_version_str REGEX "^[\t ]+LIBCEC_VERSION_TO_UINT\\(.*\\)") - string(REGEX REPLACE "^[\t ]+LIBCEC_VERSION_TO_UINT\\(([0-9]+), ([0-9]+), ([0-9]+)\\)" "\\1.\\2.\\3" CEC_VERSION "${cec_version_str}") - unset(cec_version_str) + if(CORE_SYSTEM_NAME STREQUAL "osx") + set(CEC_BYPRODUCT_EXTENSION "dylib") + endif() + + BUILD_DEP_TARGET() + + if(CORE_SYSTEM_NAME STREQUAL "osx") + find_program(INSTALL_NAME_TOOL NAMES install_name_tool) + add_custom_command(TARGET cec POST_BUILD + COMMAND ${INSTALL_NAME_TOOL} -id ${CEC_LIBRARY} ${CEC_LIBRARY}) + endif() + + add_dependencies(cec P8Platform::P8Platform) + endmacro() + + # We only need to check p8-platform if we have any intention to build internal + if(ENABLE_INTERNAL_CEC) + # Check for dependencies - Must be done before SETUP_BUILD_VARS + get_libversion_data("p8-platform" "target") + find_package(P8Platform ${LIB_P8-PLATFORM_VER} MODULE QUIET REQUIRED) + # Check if we want to force a build due to a dependency rebuild + get_property(LIB_FORCE_REBUILD TARGET P8Platform::P8Platform PROPERTY LIB_BUILD) endif() - if(NOT CEC_FIND_VERSION) - set(CEC_FIND_VERSION 4.0.0) + set(MODULE_LC cec) + + SETUP_BUILD_VARS() + + # Check for existing libcec. If version >= LIBCEC-VERSION file version, dont build + find_package(libcec CONFIG + HINTS ${DEPENDS_PATH}/lib/cmake + ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG}) + + if((libcec_VERSION VERSION_LESS ${${MODULE}_VER} AND ENABLE_INTERNAL_CEC) OR LIB_FORCE_REBUILD) + # Build lib + buildCEC() + else() + # if libcec::cec target exists, it meets version requirements + # we only do a pkgconfig search when a suitable cmake config returns nothing + if(TARGET libcec::cec) + get_target_property(_CEC_CONFIGURATIONS libcec::cec IMPORTED_CONFIGURATIONS) + foreach(_cec_config IN LISTS _CEC_CONFIGURATIONS) + # Some non standard config (eg None on Debian) + # Just set to RELEASE var so select_library_configurations can continue to work its magic + string(TOUPPER ${_cec_config} _cec_config_UPPER) + if((NOT ${_cec_config_UPPER} STREQUAL "RELEASE") AND + (NOT ${_cec_config_UPPER} STREQUAL "DEBUG")) + get_target_property(CEC_LIBRARY_RELEASE libcec::cec IMPORTED_LOCATION_${_cec_config_UPPER}) + else() + get_target_property(CEC_LIBRARY_${_cec_config_UPPER} libcec::cec IMPORTED_LOCATION_${_cec_config_UPPER}) + endif() + endforeach() + + # CEC cmake config doesnt include INTERFACE_INCLUDE_DIRECTORIES + find_path(CEC_INCLUDE_DIR NAMES libcec/cec.h libCEC/CEC.h + HINTS ${DEPENDS_PATH}/include ${PC_CEC_INCLUDEDIR} + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} + NO_CACHE) + set(CEC_VERSION ${libcec_VERSION}) + else() + find_package(PkgConfig) + # Fallback to pkg-config and individual lib/include file search + if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_CEC libcec QUIET) + endif() + find_library(CEC_LIBRARY_RELEASE NAMES cec + HINTS ${DEPENDS_PATH}/lib ${PC_CEC_LIBDIR} + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} + NO_CACHE) + + find_path(CEC_INCLUDE_DIR NAMES libcec/cec.h libCEC/CEC.h + HINTS ${DEPENDS_PATH}/include ${PC_CEC_INCLUDEDIR} + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} + NO_CACHE) + + if(PC_CEC_VERSION) + set(CEC_VERSION ${PC_CEC_VERSION}) + elseif(CEC_INCLUDE_DIR AND EXISTS "${CEC_INCLUDE_DIR}/libcec/version.h") + file(STRINGS "${CEC_INCLUDE_DIR}/libcec/version.h" cec_version_str REGEX "^[\t ]+LIBCEC_VERSION_TO_UINT\\(.*\\)") + string(REGEX REPLACE "^[\t ]+LIBCEC_VERSION_TO_UINT\\(([0-9]+), ([0-9]+), ([0-9]+)\\)" "\\1.\\2.\\3" CEC_VERSION "${cec_version_str}") + unset(cec_version_str) + endif() + endif() endif() - find_library(CEC_LIBRARY NAMES cec - PATHS ${PC_CEC_LIBDIR} - NO_CACHE) + include(SelectLibraryConfigurations) + select_library_configurations(CEC) + unset(CEC_LIBRARIES) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(CEC @@ -39,11 +125,47 @@ if(NOT TARGET CEC::CEC) VERSION_VAR CEC_VERSION) if(CEC_FOUND) - add_library(CEC::CEC UNKNOWN IMPORTED) - set_target_properties(CEC::CEC PROPERTIES - IMPORTED_LOCATION "${CEC_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${CEC_INCLUDE_DIR}" - INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC=1) + # cmake target and not building internal + if(TARGET libcec::cec AND NOT TARGET cec) + add_library(CEC::CEC ALIAS libcec::cec) + # We need to append in case the cmake config already has definitions + set_property(TARGET libcec::cec APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC=1) + # pkgconfig target found + elseif(TARGET PkgConfig::PC_CEC) + add_library(CEC::CEC ALIAS PkgConfig::PC_CEC) + set_property(TARGET PkgConfig::PC_CEC APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC=1) + # building internal or no cmake config or pkgconfig + else() + add_library(CEC::CEC UNKNOWN IMPORTED) + set_target_properties(CEC::CEC PROPERTIES + IMPORTED_LOCATION "${CEC_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${CEC_INCLUDE_DIR}" + INTERFACE_COMPILE_DEFINITIONS HAVE_LIBCEC=1) + endif() + + if(TARGET cec) + add_dependencies(CEC::CEC cec) + endif() + + # Add internal build target when a Multi Config Generator is used + # We cant add a dependency based off a generator expression for targeted build types, + # https://gitlab.kitware.com/cmake/cmake/-/issues/19467 + # therefore if the find heuristics only find the library, we add the internal build + # target to the project to allow user to manually trigger for any build type they need + # in case only a specific build type is actually available (eg Release found, Debug Required) + # This is mainly targeted for windows who required different runtime libs for different + # types, and they arent compatible + if(_multiconfig_generator) + if(NOT TARGET cec) + buildCEC() + set_target_properties(cec PROPERTIES EXCLUDE_FROM_ALL TRUE) + endif() + add_dependencies(build_internal_depends cec) + endif() + set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP CEC::CEC) + endif() endif() diff --git a/cmake/modules/FindFmt.cmake b/cmake/modules/FindFmt.cmake index cf78e6d24e..6a3f36eab8 100644 --- a/cmake/modules/FindFmt.cmake +++ b/cmake/modules/FindFmt.cmake @@ -36,8 +36,6 @@ if(NOT TARGET fmt::fmt) endmacro() set(MODULE_LC fmt) - # Default state - set(FORCE_BUILD OFF) SETUP_BUILD_VARS() @@ -46,12 +44,9 @@ if(NOT TARGET fmt::fmt) HINTS ${DEPENDS_PATH}/lib/cmake ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG}) - if((FMT_VERSION VERSION_LESS ${${MODULE}_VER} AND ENABLE_INTERNAL_FMT) OR ((CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd) AND ENABLE_INTERNAL_FMT)) - - # Set FORCE_BUILD to enable fmt::fmt property that build will occur - set(FORCE_BUILD ON) + # build internal module buildFmt() else() if(NOT TARGET fmt::fmt) @@ -131,10 +126,9 @@ if(NOT TARGET fmt::fmt) if(TARGET fmt) add_dependencies(fmt::fmt fmt) - # If a force build is done, let any calling packages know they may want to rebuild - if(FORCE_BUILD) - set_target_properties(fmt::fmt PROPERTIES LIB_BUILD ON) - endif() + # We are building as a requirement, so set LIB_BUILD property to allow calling + # modules to know we will be building, and they will want to rebuild as well. + set_target_properties(fmt::fmt PROPERTIES LIB_BUILD ON) endif() # Add internal build target when a Multi Config Generator is used diff --git a/cmake/modules/FindP8Platform.cmake b/cmake/modules/FindP8Platform.cmake new file mode 100644 index 0000000000..e80fe9768c --- /dev/null +++ b/cmake/modules/FindP8Platform.cmake @@ -0,0 +1,113 @@ +# FindP8Platform +# ------- +# Finds the P8-Platform library +# +# This will define the following target: +# +# P8Platform::P8Platform - The P8-Platform library + +# If find_package REQUIRED, check again to make sure any potential versions +# supplied in the call match what we can find/build +if(NOT P8Platform::P8Platform OR P8Platform_FIND_REQUIRED) + include(cmake/scripts/common/ModuleHelpers.cmake) + + macro(buildlibp8platform) + set(patches "${CORE_SOURCE_DIR}/tools/depends/target/${MODULE_LC}/001-all-fix-c++17-support.patch" + "${CORE_SOURCE_DIR}/tools/depends/target/${MODULE_LC}/002-all-fixcmakeinstall.patch" + "${CORE_SOURCE_DIR}/tools/depends/target/${MODULE_LC}/003-all-cmake_tweakversion.patch") + + generate_patchcommand("${patches}") + + set(CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF) + + # CMAKE_INSTALL_LIBDIR in p8-platform prepends project prefix, so disable sending any + # install_libdir to generator + set(P8-PLATFORM_INSTALL_LIBDIR "/lib") + + set(BUILD_NAME build-${MODULE_LC}) + + BUILD_DEP_TARGET() + + set(P8-PLATFORM_VERSION ${${MODULE}_VER}) + endmacro() + + set(MODULE_LC p8-platform) + SETUP_BUILD_VARS() + + # Search cmake-config. Suitable all platforms + find_package(p8-platform CONFIG + HINTS ${DEPENDS_PATH}/lib/cmake + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG}) + + if(p8-platform_VERSION VERSION_LESS ${${MODULE}_VER}) + # build p8-platform lib + buildlibp8platform() + else() + # p8-platform cmake config is terrible for modern cmake. For now just use pkgconfig + # and manual find_* + find_package(PkgConfig) + # Do not use pkgconfig on windows + if(PKG_CONFIG_FOUND AND NOT WIN32) + pkg_check_modules(PC_P8PLATFORM p8-platform QUIET) + set(P8-PLATFORM_VERSION ${PC_P8PLATFORM_VERSION}) + else() + set(P8-PLATFORM_VERSION ${p8-platform_VERSION}) + endif() + + # Hack: kodi uses a tweak version. Along with p8platform cmake config/pkgconfig + # returns versions without patch. Just skip for now + set(P8Platform_FIND_VERSION "2.1") + find_library(P8-PLATFORM_LIBRARY NAMES p8-platform + HINTS ${DEPENDS_PATH}/lib ${PC_P8PLATFORM_LIBDIR} + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} + NO_CACHE) + find_path(P8-PLATFORM_INCLUDE_DIR NAMES p8-platform/os.h + HINTS ${DEPENDS_PATH}/include ${PC_P8PLATFORM_INCLUDEDIR} + ${${CORE_PLATFORM_LC}_SEARCH_CONFIG} + NO_CACHE) + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(P8Platform + REQUIRED_VARS P8-PLATFORM_LIBRARY P8-PLATFORM_INCLUDE_DIR + VERSION_VAR P8-PLATFORM_VERSION) + + if(P8PLATFORM_FOUND) + add_library(P8Platform::P8Platform UNKNOWN IMPORTED) + set_target_properties(P8Platform::P8Platform PROPERTIES + IMPORTED_LOCATION "${P8-PLATFORM_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${P8-PLATFORM_INCLUDE_DIR}") + + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set_target_properties(P8Platform::P8Platform PROPERTIES + INTERFACE_LINK_LIBRARIES "-framework CoreVideo") + endif() + + if(TARGET build-p8-platform) + add_dependencies(P8Platform::P8Platform build-p8-platform) + # If the build target exists here, set LIB_BUILD property to allow calling modules + # know that this will be rebuilt, and they will need to rebuild as well + set_target_properties(P8Platform::P8Platform PROPERTIES LIB_BUILD ON) + endif() + + # Add internal build target when a Multi Config Generator is used + # We cant add a dependency based off a generator expression for targeted build types, + # https://gitlab.kitware.com/cmake/cmake/-/issues/19467 + # therefore if the find heuristics only find the library, we add the internal build + # target to the project to allow user to manually trigger for any build type they need + # in case only a specific build type is actually available (eg Release found, Debug Required) + # This is mainly targeted for windows who required different runtime libs for different + # types, and they arent compatible + if(_multiconfig_generator) + if(NOT TARGET build-p8-platform) + buildlibp8platform() + set_target_properties(build-p8-platform PROPERTIES EXCLUDE_FROM_ALL TRUE) + endif() + add_dependencies(build_internal_depends build-p8-platform) + endif() + else() + if(P8PLATFORM_FIND_REQUIRED) + message(FATAL_ERROR "P8-PLATFORM not found.") + endif() + endif() +endif() diff --git a/cmake/platform/android/android.cmake b/cmake/platform/android/android.cmake index 07fa72c746..26c7821f89 100644 --- a/cmake/platform/android/android.cmake +++ b/cmake/platform/android/android.cmake @@ -1,4 +1,5 @@ set(PLATFORM_REQUIRED_DEPS LibAndroidJNI OpenGLES EGL LibZip) +set(PLATFORM_OPTIONAL_DEPS_EXCLUDE CEC) set(APP_RENDER_SYSTEM gles) list(APPEND PLATFORM_OPTIONAL_DEPS LibDovi) diff --git a/cmake/platform/darwin_embedded/ios.cmake b/cmake/platform/darwin_embedded/ios.cmake index aff02ecfc6..860023d2f2 100644 --- a/cmake/platform/darwin_embedded/ios.cmake +++ b/cmake/platform/darwin_embedded/ios.cmake @@ -1,3 +1,4 @@ list(APPEND ARCH_DEFINES -DTARGET_DARWIN_IOS) set(${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG NO_DEFAULT_PATH CACHE STRING "") +set(PLATFORM_OPTIONAL_DEPS_EXCLUDE CEC) diff --git a/cmake/platform/darwin_embedded/tvos.cmake b/cmake/platform/darwin_embedded/tvos.cmake index 62e16f5c06..f30a7a5eb4 100644 --- a/cmake/platform/darwin_embedded/tvos.cmake +++ b/cmake/platform/darwin_embedded/tvos.cmake @@ -1,3 +1,5 @@ list(APPEND ARCH_DEFINES -DTARGET_DARWIN_TVOS) set(ENABLE_AIRTUNES OFF CACHE BOOL "" FORCE) set(${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG NO_DEFAULT_PATH CACHE STRING "") +set(PLATFORM_OPTIONAL_DEPS_EXCLUDE CEC) + diff --git a/cmake/platform/linux/webos.cmake b/cmake/platform/linux/webos.cmake index ce60f79cce..d646a08400 100644 --- a/cmake/platform/linux/webos.cmake +++ b/cmake/platform/linux/webos.cmake @@ -6,6 +6,7 @@ list(APPEND CORE_PLATFORM_NAME_LC wayland) list(APPEND PLATFORM_REQUIRED_DEPS WaylandProtocolsWebOS PlayerAPIs PlayerFactory WebOSHelpers AcbAPI) list(APPEND ARCH_DEFINES -DTARGET_WEBOS) +set(PLATFORM_OPTIONAL_DEPS_EXCLUDE CEC) set(ENABLE_PULSEAUDIO OFF CACHE BOOL "" FORCE) set(TARGET_WEBOS TRUE) set(PREFER_TOOLCHAIN_PATH ${TOOLCHAIN}/${HOST}/sysroot) diff --git a/cmake/platform/windowsstore/windowsstore.cmake b/cmake/platform/windowsstore/windowsstore.cmake index 50eb55599c..6fa4687720 100644 --- a/cmake/platform/windowsstore/windowsstore.cmake +++ b/cmake/platform/windowsstore/windowsstore.cmake @@ -1,4 +1,5 @@ set(PLATFORM_REQUIRED_DEPS D3DX11Effects) +set(PLATFORM_OPTIONAL_DEPS_EXCLUDE CEC) set(APP_RENDER_SYSTEM dx11) set(${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG NO_DEFAULT_PATH CACHE STRING "") diff --git a/cmake/scripts/common/Macros.cmake b/cmake/scripts/common/Macros.cmake index 31d8f16e0e..967010bc54 100644 --- a/cmake/scripts/common/Macros.cmake +++ b/cmake/scripts/common/Macros.cmake @@ -250,8 +250,18 @@ function(copy_file_to_buildtree file) endif() if(${CORE_SYSTEM_NAME} MATCHES "windows") - file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake - "file(COPY \"${file}\" DESTINATION \"\$\{BUNDLEDIR\}/${outdir}\")\n" ) + # if DEPENDS_PATH in fille + if(${file} MATCHES ${DEPENDS_PATH}) + file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake +"file(GLOB filenames ${file}) +foreach(filename \$\{filenames\}) + file(COPY \"\$\{filename\}\" DESTINATION \"\$\{BUNDLEDIR\}/${outdir}\") +endforeach()\n" + ) + else() + file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake + "file(COPY \"${file}\" DESTINATION \"\$\{BUNDLEDIR\}/${outdir}\")\n" ) + endif() else() if(NOT file STREQUAL ${CMAKE_BINARY_DIR}/${outfile}) if(NOT IS_SYMLINK "${file}") @@ -321,11 +331,16 @@ function(copy_files_from_filelist_to_buildtree pattern) list(GET dir -1 dest) endif() - # If the full path to an existing file is specified then add that single file. - # Don't recursively add all files with the given name. - if(EXISTS ${CMAKE_SOURCE_DIR}/${src} AND (NOT IS_DIRECTORY ${CMAKE_SOURCE_DIR}/${src} OR DIR_OPTION)) + if((${CMAKE_SOURCE_DIR}/${src} MATCHES ${DEPENDS_PATH}) OR + (EXISTS ${CMAKE_SOURCE_DIR}/${src} AND (NOT IS_DIRECTORY ${CMAKE_SOURCE_DIR}/${src} OR DIR_OPTION))) + # If the path is in DEPENDS_PATH, pass through as is. This will be handled in a build time + # glob of the location. This insures any dependencies built at build time can be bundled if + # required. + # OR If the full path to an existing file is specified then add that single file. + # Don't recursively add all files with the given name. set(files ${src}) else() + # Static path contents, so we can just glob at generation time file(GLOB_RECURSE files RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/${src}) endif() diff --git a/cmake/scripts/common/ModuleHelpers.cmake b/cmake/scripts/common/ModuleHelpers.cmake index 7bd5847974..6f44ae3d35 100644 --- a/cmake/scripts/common/ModuleHelpers.cmake +++ b/cmake/scripts/common/ModuleHelpers.cmake @@ -223,7 +223,6 @@ macro(BUILD_DEP_TARGET) if(CMAKE_ARGS) set(CMAKE_ARGS CMAKE_ARGS ${CMAKE_ARGS} - -DCMAKE_INSTALL_LIBDIR=lib -DPROJECTSOURCE=${PROJECTSOURCE} "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}") @@ -239,6 +238,12 @@ macro(BUILD_DEP_TARGET) endif() endif() + if(DEFINED ${MODULE}_INSTALL_LIBDIR) + list(APPEND CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=${${MODULE}_INSTALL_LIBDIR}) + else() + list(APPEND CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=lib) + endif() + if(${MODULE}_INSTALL_PREFIX) list(APPEND CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${${MODULE}_INSTALL_PREFIX}) else() @@ -326,6 +331,14 @@ macro(BUILD_DEP_TARGET) set(BUILD_IN_SOURCE BUILD_IN_SOURCE ${BUILD_IN_SOURCE}) endif() + # Change extension of BYPRODUCT + # eg, Macos uses dylib for shared libs, but all other unix platforms use .so + if(${MODULE}_BYPRODUCT_EXTENSION) + string(REGEX REPLACE "\\.[^.]*$" "" _LIBNAME ${${MODULE}_BYPRODUCT}) + set(${MODULE}_BYPRODUCT "${_LIBNAME}.${${MODULE}_BYPRODUCT_EXTENSION}") + unset(_LIBNAME) + endif() + # Set Library names. if(DEFINED ${MODULE}_DEBUG_POSTFIX) set(_POSTFIX ${${MODULE}_DEBUG_POSTFIX}) |