This commit is contained in:
Andrei Astafev 2022-10-02 16:22:43 +03:00
parent 8aa8ceef6b
commit 0e0424cf5f
7 changed files with 42 additions and 26 deletions

View File

@ -9,6 +9,8 @@ get_filename_component(MYX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTO
set(MYX_CMAKE_BACKPORTS_DIR "${MYX_CMAKE_SOURCE_DIR}/backports") set(MYX_CMAKE_BACKPORTS_DIR "${MYX_CMAKE_SOURCE_DIR}/backports")
set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib") set(MYX_CMAKE_LIB_DIR "${MYX_CMAKE_SOURCE_DIR}/lib")
include(${MYX_CMAKE_LIB_DIR}/macro/InstallRelative.cmake)
include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake) include(${MYX_CMAKE_BACKPORTS_DIR}/IncludeGuard.cmake)
include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake) include(${MYX_CMAKE_BACKPORTS_DIR}/TopLevelProject.cmake)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0") if(${CMAKE_VERSION} VERSION_LESS "3.11.0")

View File

@ -1,4 +1,4 @@
set(MYX_CMAKE_PACKAGE_VERSION "1.99.41") set(MYX_CMAKE_PACKAGE_VERSION "1.99.42")
if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) if(MYX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE) set(PACKAGE_VERSION_COMPATIBLE FALSE)
else() else()

View File

@ -12,7 +12,7 @@
```cmake ```cmake
if(MYX_CMAKE_USE_SYSTEM) if(MYX_CMAKE_USE_SYSTEM)
find_package(MyxCMake 1.99.41 REQUIRED) find_package(MyxCMake 1.99.42 REQUIRED)
else() else()
include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake) include(${PROJECT_SOURCE_DIR}/cmake/myx/MyxCMakeConfig.cmake)
endif() endif()

View File

@ -1 +1 @@
1.99.41 1.99.42

View File

@ -88,6 +88,7 @@ function(myx_add_library NAME TYPE)
EXPORT_FILE_NAME ${ARG_EXPORT_FILE_NAME} EXPORT_FILE_NAME ${ARG_EXPORT_FILE_NAME}
DEFINE_NO_DEPRECATED DEFINE_NO_DEPRECATED
) )
set_property(TARGET ${NAME} APPEND PROPERTY INTERFACE_HEADER_FILES "${ARG_EXPORT_FILE_NAME}")
# Цель для создания динамической библиотеки из объектных файлов # Цель для создания динамической библиотеки из объектных файлов
if(${PROJECT_NAME_UPPER}_BUILD_SHARED) if(${PROJECT_NAME_UPPER}_BUILD_SHARED)
@ -190,12 +191,6 @@ function(myx_add_library NAME TYPE)
COMPONENT dev COMPONENT dev
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
# Установка содержимого каталога с заголовочными файлами
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT dev
)
if(TYPE STREQUAL "OBJECT") if(TYPE STREQUAL "OBJECT")
# Установка динамической библиотеки # Установка динамической библиотеки
if(TARGET ${NAME}_shared) if(TARGET ${NAME}_shared)

View File

@ -3,14 +3,14 @@ include_guard(GLOBAL)
function(myx_qt5_target_setup NAME) function(myx_qt5_target_setup NAME)
set(options) set(options)
set(oneValueArgs) set(oneValueArgs)
set(multiValueArgs COMPONENTS PRIVATE CPP HPP MOC UI QRC LANGS SOURCES) set(multiValueArgs COMPONENTS PRIVATE PUBLIC_MOC PRIVATE_MOC UI QRC LANGS)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
get_target_property(type ${NAME} TYPE) get_target_property(type ${NAME} TYPE)
if(ARG_SOURCES) if(ARG_SOURCES OR ARG_CPP OR ARG_HPP OR ARG_MOD)
myx_message_deprecation("MyxCMake: Use CPP and HPP arguments instead of SOURCES") myx_message_fatal_error("MyxCMake: prohibited use")
endif() endif()
if(ARG_COMPONENTS) if(ARG_COMPONENTS)
@ -33,16 +33,16 @@ function(myx_qt5_target_setup NAME)
target_compile_options(${NAME} PRIVATE ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}) target_compile_options(${NAME} PRIVATE ${Qt5Core_EXECUTABLE_COMPILE_FLAGS})
endif() endif()
if(ARG_CPP) if(ARG_PUBLIC_MOC)
set_target_properties(${NAME} PROPERTIES CPP_FILES ${ARG_CPP}) set_property(TARGET ${NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_MOC}")
endif() endif()
if(ARG_HPP OR ARG_MOC) if(ARG_PRIVATE_MOC)
set_target_properties(${NAME} PROPERTIES HPP_FILES ${ARG_HPP} ${ARG_MOC}) set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_MOC}")
endif() endif()
if(ARG_MOC) if(ARG_PUBLIC_MOC OR ARG_PRIVATE_MOC)
qt5_wrap_cpp(moc_cpp ${ARG_MOC}) qt5_wrap_cpp(moc_cpp ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC})
endif() endif()
if(ARG_QRC) if(ARG_QRC)
@ -64,6 +64,12 @@ function(myx_qt5_target_setup NAME)
unset(qm) unset(qm)
endif() endif()
target_sources(${NAME} PRIVATE ${ARG_HPP} ${ARG_CPP} ${ARG_SOURCES} ${ARG_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp}) target_sources(${NAME} PRIVATE ${ARG_PUBLIC_MOC} ${ARG_PRIVATE_MOC} ${moc_cpp} ${ui_h} ${qrc_cpp})
# Установка публичных заголовочных файлов
install_relative(${PROJECT_SOURCE_DIR}
FILES ${ARG_PUBLIC_MOC}
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT dev
)
endfunction() endfunction()

View File

@ -3,7 +3,8 @@ include_guard(GLOBAL)
function(myx_target_setup NAME) function(myx_target_setup NAME)
set(options) set(options)
set(oneValueArgs PCH) set(oneValueArgs PCH)
set(multiValueArgs COMPILE_DEFINITIONS FIND_PACKAGES LINK_LIBRARIES CPP HPP SOURCES) set(multiValueArgs COMPILE_DEFINITIONS FIND_PACKAGES LINK_LIBRARIES
CPP PUBLIC_HEADERS PRIVATE_HEADERS SOURCES)
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@ -21,15 +22,19 @@ function(myx_target_setup NAME)
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS}) target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
if(ARG_SOURCES) if(ARG_SOURCES)
myx_message_deprecation("MyxCMake: Use CPP and HPP arguments instead of SOURCES") myx_message_fatal_error("MyxCMake: Use of SOURCES argument")
endif() endif()
if(ARG_CPP) if(ARG_CPP)
set_target_properties(${NAME} PROPERTIES CPP_FILES ${ARG_CPP}) set_property(TARGET ${NAME} APPEND PROPERTY CPP_FILES ${ARG_CPP})
endif() endif()
if(ARG_HPP) if(ARG_PUBLIC_HEADERS)
set_target_properties(${NAME} PROPERTIES HPP_FILES ${ARG_HPP}) set_property(TARGET ${NAME} APPEND PROPERTY PUBLIC_HEADER_FILES "${ARG_PUBLIC_HEADERS}")
endif()
if(ARG_PUBLIC_HEADERS)
set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PRIVATE_HEADERS}")
endif() endif()
if(ARG_PCH) if(ARG_PCH)
@ -38,7 +43,7 @@ function(myx_target_setup NAME)
else() else()
target_compile_options(${NAME} PRIVATE -include ${ARG_PCH}) target_compile_options(${NAME} PRIVATE -include ${ARG_PCH})
endif() endif()
target_sources(${NAME} PRIVATE ${ARG_PCH}) set_property(TARGET ${NAME} APPEND PROPERTY PRIVATE_HEADER_FILES "${ARG_PCH}")
endif() endif()
target_include_directories(${PROJECT_NAME} PRIVATE target_include_directories(${PROJECT_NAME} PRIVATE
@ -65,7 +70,15 @@ function(myx_target_setup NAME)
install(TARGETS ${NAME} COMPONENT main RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS ${NAME} COMPONENT main RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif() endif()
target_sources(${NAME} PRIVATE ${ARG_CPP} ${ARG_HPP} ${ARG_SOURCES}) target_sources(${NAME} PUBLIC ${ARG_PUBLIC_HEADERS})
target_sources(${NAME} PRIVATE ${ARG_CPP} ${ARG_PCH} ${ARG_PRIVATE_HEADERS})
target_link_libraries(${NAME} PRIVATE ${ARG_LINK_LIBRARIES}) target_link_libraries(${NAME} PRIVATE ${ARG_LINK_LIBRARIES})
target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS}) target_compile_definitions(${NAME} PRIVATE ${ARG_COMPILE_DEFINITIONS})
# Установка публичных заголовочных файлов
install_relative(${PROJECT_SOURCE_DIR}
FILES ${ARG_PUBLIC_HEADERS}
DESTINATION ${CMAKE_INSTALL_PREFIX}
COMPONENT dev
)
endfunction() endfunction()