diff --git a/CMLibCommonLibraryTarget.cmake b/CMLibCommonLibraryTarget.cmake index 601b43a..7056c62 100644 --- a/CMLibCommonLibraryTarget.cmake +++ b/CMLibCommonLibraryTarget.cmake @@ -20,6 +20,6 @@ function(add_common_library LIBNAME SOURCES) set_target_properties(${LIBNAME}_static PROPERTIES OUTPUT_NAME ${LIBNAME} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_INSTALL_LIBDIR}) - configure_file(${CMAKE_SOURCE_DIR}/cmake/cmlib/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${LIBNAME}.pc) + configure_file(${CMLIB_MODULE_DIR}/pc/lib.pc.in ${CMAKE_BINARY_DIR}/${LIBNAME}.pc) endfunction() diff --git a/CMLibConfigHPPGenerate.cmake b/CMLibConfigHPPGenerate.cmake index 34f536c..427e360 100644 --- a/CMLibConfigHPPGenerate.cmake +++ b/CMLibConfigHPPGenerate.cmake @@ -2,5 +2,5 @@ function(cmlib_config_hpp_generate) get_property(VERSION_INT GLOBAL PROPERTY VERSION_INT) get_property(VERSION_STR GLOBAL PROPERTY VERSION_STR) get_property(ORGANIZATION_NAME GLOBAL PROPERTY ORGANIZATION_NAME) - configure_file(${CMAKE_SOURCE_DIR}/cmake/cmlib/hpp/config.hpp.in ${CMAKE_BINARY_DIR}/include/config.hpp) + configure_file(${CMLIB_MODULE_DIR}/hpp/config.hpp.in ${CMAKE_BINARY_DIR}/include/config.hpp) endfunction() diff --git a/CMLibGlobalVariables.cmake b/CMLibGlobalVariables.cmake index 22dc80c..78eb3a7 100644 --- a/CMLibGlobalVariables.cmake +++ b/CMLibGlobalVariables.cmake @@ -3,3 +3,12 @@ string(TOUPPER ${PROJECT_NAME} _project_name_uppercase) string(REGEX REPLACE "[ -]" "_" _project_name_fixed ${_project_name_uppercase}) set(CMLIB_PROJECT_NAME_CANONICAL ${_project_name_fixed}) +# CMLIB_MODULE_DIR +set(CMLIB_MODULE_DIR "") +foreach(_m ${CMAKE_MODULE_PATH}) + if(EXISTS ${_m}/CMLibCommon.cmake) + get_filename_component(CMLIB_MODULE_DIR ${_m}/CMLibCommon.cmake DIRECTORY) + break() + endif() +endforeach() + diff --git a/CMLibLargeFiles.cmake b/CMLibLargeFiles.cmake index a743b71..5ca9ddf 100644 --- a/CMLibLargeFiles.cmake +++ b/CMLibLargeFiles.cmake @@ -10,7 +10,7 @@ macro(test_large_files VARIABLE USE_64_SUFFIX) # First try without any macros defined try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}" - "${CMAKE_MODULE_PATH}/tests/LargeFiles${SUFFIX_64}.c" + "${CMLIB_MODULE_DIR}/tests/LargeFiles${SUFFIX_64}.c" OUTPUT_VARIABLE TRY_LARGE_FILES_OUTPUT) if(VERBOSE_LARGE_FILES) @@ -20,7 +20,7 @@ macro(test_large_files VARIABLE USE_64_SUFFIX) if(NOT LARGE_FILES_SUPPORTED) # Try with C macro _FILE_OFFSET_BITS=64 try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}" - "${CMAKE_MODULE_PATH}/tests/LargeFiles${SUFFIX_64}.c" + "${CMLIB_MODULE_DIR}/tests/LargeFiles${SUFFIX_64}.c" COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" OUTPUT_VARIABLE TRY_LARGE_FILES_OUTPUT) @@ -37,7 +37,7 @@ macro(test_large_files VARIABLE USE_64_SUFFIX) # Try with C macro _LARGEFILE_SOURCE try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}" - "${CMAKE_MODULE_PATH}/tests/LargeFiles${SUFFIX_64}.c" + "${CMLIB_MODULE_DIR}/tests/LargeFiles${SUFFIX_64}.c" COMPILE_DEFINITIONS "-D_LARGEFILE${SUFFIX_64}_SOURCE" OUTPUT_VARIABLE TRY_LARGE_FILES_OUTPUT) @@ -53,7 +53,7 @@ macro(test_large_files VARIABLE USE_64_SUFFIX) if(NOT LARGE_FILES_SUPPORTED) # Try with both C macro _FILE_OFFSET_BITS=64 and _LARGEFILE_SOURCE try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}" - "${CMAKE_MODULE_PATH}/tests/LargeFiles${SUFFIX_64}.c" + "${CMLIB_MODULE_DIR}/tests/LargeFiles${SUFFIX_64}.c" COMPILE_DEFINITIONS "-D_FILE_OFFSET_BITS=64" "-D_LARGEFILE${SUFFIX_64}_SOURCE" OUTPUT_VARIABLE TRY_LARGE_FILES_OUTPUT) @@ -70,7 +70,7 @@ macro(test_large_files VARIABLE USE_64_SUFFIX) if(NOT LARGE_FILES_SUPPORTED) # Maybe we are using the Windows C standard library try_compile(LARGE_FILES_SUPPORTED "${CMAKE_BINARY_DIR}" - "${CMAKE_MODULE_PATH}/tests/LargeFilesWindows.c") + "${CMLIB_MODULE_DIR}/tests/LargeFilesWindows.c") endif(NOT LARGE_FILES_SUPPORTED) if(LARGE_FILES_SUPPORTED) diff --git a/CMLibQtTranslation.cmake b/CMLibQtTranslation.cmake index 650917e..65e980b 100644 --- a/CMLibQtTranslation.cmake +++ b/CMLibQtTranslation.cmake @@ -40,7 +40,7 @@ function(qt_translation) COMMAND ${Qt5_LUPDATE_EXECUTABLE} ARGS ${_sources_list} -ts ${_ts_list} DEPENDS ${_sources_list}) - configure_file(${CMAKE_SOURCE_DIR}/cmake/cmlib/qrc/l10n.qrc.in ${CMAKE_BINARY_DIR}/${_target}_l10n.qrc) + configure_file(${CMLIB_MODULE_DIR}/qrc/l10n.qrc.in ${CMAKE_BINARY_DIR}/${_target}_l10n.qrc) qt5_add_resources(_qrc ${CMAKE_BINARY_DIR}/${_target}_l10n.qrc) add_custom_target(_qrc_target DEPENDS ${_qrc}) diff --git a/CMLibUninstall.cmake b/CMLibUninstall.cmake index 1c4d360..78ec366 100644 --- a/CMLibUninstall.cmake +++ b/CMLibUninstall.cmake @@ -1,6 +1,6 @@ if(NOT TARGET uninstall) configure_file( - "${CMAKE_SOURCE_DIR}/cmake/cmlib/CMLibUninstall.cmake.in" + "${CMLIB_MODULE_DIR}/CMLibUninstall.cmake.in" "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)