update
This commit is contained in:
parent
03da054787
commit
f6ff19e9f5
@ -3,23 +3,22 @@ cmake_policy(SET CMP0057 NEW) # IN_LIST operator
|
||||
|
||||
get_filename_component(MYX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
|
||||
|
||||
set(MYX_CMAKE_CONFIG_DIR "${MYX_CMAKE_SOURCE_DIR}/config")
|
||||
set(MYX_CMAKE_BACKPORTS_DIR "${MYX_CMAKE_SOURCE_DIR}/backports")
|
||||
set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib")
|
||||
|
||||
include(${MYX_CMAKE_CONFIG_DIR}/Globals.cmake)
|
||||
|
||||
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
|
||||
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
|
||||
include(${MYX_CMAKE_BACKPORTS_DIR}/FetchContent.cmake)
|
||||
endif()
|
||||
|
||||
include(${MYX_CMAKE_LIB_DIR}/Includes.cmake)
|
||||
include(${MYX_CMAKE_LIB_DIR}/ColoredMessages.cmake)
|
||||
include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWarning.cmake)
|
||||
include(${MYX_CMAKE_LIB_DIR}/DirectoriesGuards.cmake)
|
||||
include(${MYX_CMAKE_LIB_DIR}/SemanticProjectVersion.cmake)
|
||||
include(${MYX_CMAKE_LIB_DIR}/NinjaGeneratorWrapper.cmake)
|
||||
include(${MYX_CMAKE_LIB_DIR}/FetchContentAdd.cmake)
|
||||
|
||||
include(${MYX_CMAKE_LIB_DIR}/AddLibrary.cmake)
|
||||
include(${MYX_CMAKE_LIB_DIR}/InstallLibrary.cmake)
|
||||
@ -28,7 +27,6 @@ include(${MYX_CMAKE_LIB_DIR}/Qt5TargetSetup.cmake)
|
||||
|
||||
unset(MYX_CMAKE_SOURCE_DIR)
|
||||
unset(MYX_CMAKE_BACKPORTS_DIR)
|
||||
unset(MYX_CMAKE_CONFIG_DIR)
|
||||
unset(MYX_CMAKE_LIB_DIR)
|
||||
|
||||
cmake_policy(POP)
|
||||
|
@ -1,8 +0,0 @@
|
||||
include(GNUInstallDirs)
|
||||
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} PARENT_SCOPE)
|
||||
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR} PARENT_SCOPE)
|
||||
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR} PARENT_SCOPE)
|
||||
|
||||
#set(MYX_CMAKE_SCRIPTS_PREFIX ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} PARENT_SCOPE)
|
||||
|
35
cmake/myx/lib/FetchContentAdd.cmake
Normal file
35
cmake/myx/lib/FetchContentAdd.cmake
Normal file
@ -0,0 +1,35 @@
|
||||
include_guard(GLOBAL)
|
||||
|
||||
function(FetchContent_Add NAME)
|
||||
set(options "")
|
||||
set(oneValueArgs GIT_REPOSITORY GIT_REMOTE GIT_PATH)
|
||||
set(multiValueArgs "")
|
||||
|
||||
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
find_package(Git)
|
||||
if(GIT_FOUND AND arg_GIT_REMOTE AND arg_GIT_PATH)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} config --get remote.${arg_GIT_REMOTE}.url OUTPUT_VARIABLE REMOTE_URL ERROR_QUIET)
|
||||
if(REMOTE_URL)
|
||||
string(REGEX REPLACE ":.*" "" SERVER ${REMOTE_URL})
|
||||
string(FIND ${SERVER} "http" POS)
|
||||
if(NOT POS EQUAL 0)
|
||||
if(NOT SERVER STREQUAL REMOTE_URL)
|
||||
set(arg_GIT_REPOSITORY "${SERVER}:${arg_GIT_PATH}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(
|
||||
${NAME}
|
||||
${arg_UNPARSED_ARGUMENTS}
|
||||
GIT_REPOSITORY ${arg_GIT_REPOSITORY}
|
||||
)
|
||||
|
||||
if(NOT ${NAME}_POPULATED)
|
||||
FetchContent_Populate(${NAME})
|
||||
add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
endfunction()
|
4
cmake/myx/lib/Includes.cmake
Normal file
4
cmake/myx/lib/Includes.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
include_guard(GLOBAL)
|
||||
|
||||
include(FetchContent)
|
||||
include(GNUInstallDirs)
|
@ -31,27 +31,17 @@ function(myx_install_library NAME)
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
get_target_property(type ${NAME} TYPE)
|
||||
if(type STREQUAL INTERFACE_LIBRARY)
|
||||
install(
|
||||
TARGETS ${NAME}
|
||||
EXPORT ${NAME}Targets
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT lib
|
||||
)
|
||||
endif()
|
||||
|
||||
install(
|
||||
EXPORT ${NAME}Targets
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${PROJECT_BINARY_DIR}/${NAME}ConfigVersion.cmake
|
||||
${PROJECT_BINARY_DIR}/${NAME}Config.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
if(type STREQUAL OBJECT)
|
||||
if(TARGET ${NAME}_shared)
|
||||
install(
|
||||
TARGETS ${NAME}_shared
|
||||
@ -69,4 +59,20 @@ function(myx_install_library NAME)
|
||||
COMPONENT lib
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(
|
||||
EXPORT ${NAME}Targets
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
${PROJECT_BINARY_DIR}/${NAME}ConfigVersion.cmake
|
||||
${PROJECT_BINARY_DIR}/${NAME}Config.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${NAME}
|
||||
COMPONENT dev
|
||||
)
|
||||
|
||||
endfunction()
|
||||
|
Loading…
Reference in New Issue
Block a user