Compare commits

..

3 Commits

4 changed files with 25 additions and 14 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(myx-cmake VERSION 0.4.4 LANGUAGES) project(myx-cmake VERSION 0.4.5 LANGUAGES)
include(GNUInstallDirs) include(GNUInstallDirs)
file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake

View File

@ -10,10 +10,15 @@ function(myx_cmake_add_shared_library target)
myx_cmake_message_error("MyxCMake: myx_cmake_add_shared_library needs target of type OBJECT_LIBRARY") myx_cmake_message_error("MyxCMake: myx_cmake_add_shared_library needs target of type OBJECT_LIBRARY")
endif() endif()
get_target_property(__output_name ${target} OUTPUT_NAME)
if(NOT __output_name)
set(__output_name ${target})
endif()
add_library(${target}-shared SHARED $<TARGET_OBJECTS:${target}>) add_library(${target}-shared SHARED $<TARGET_OBJECTS:${target}>)
set_target_properties( # cmake-format: off
${target}-shared set_target_properties(${target}-shared
PROPERTIES OUTPUT_NAME ${target} PROPERTIES OUTPUT_NAME ${__output_name}
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR} SOVERSION ${PROJECT_VERSION_MAJOR}
LIBRARY_OUTPUT_DIRECTORY LIBRARY_OUTPUT_DIRECTORY
@ -21,4 +26,5 @@ function(myx_cmake_add_shared_library target)
install(TARGETS ${target}-shared install(TARGETS ${target}-shared
COMPONENT main COMPONENT main
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
# cmake-format: on
endfunction() endfunction()

View File

@ -10,13 +10,18 @@ function(myx_cmake_add_static_library target)
myx_cmake_message_error("MyxCMake: myx_cmake_add_static_library needs target of type OBJECT_LIBRARY") myx_cmake_message_error("MyxCMake: myx_cmake_add_static_library needs target of type OBJECT_LIBRARY")
endif() endif()
get_target_property(__output_name ${target} OUTPUT_NAME)
if(NOT __output_name)
set(__output_name ${target})
endif()
add_library(${target}-static STATIC $<TARGET_OBJECTS:${target}>) add_library(${target}-static STATIC $<TARGET_OBJECTS:${target}>)
# cmake-format: off
set_target_properties(${target}-static set_target_properties(${target}-static
PROPERTIES PROPERTIES OUTPUT_NAME ${__output_name}
OUTPUT_NAME ${target} ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${target}-static install(TARGETS ${target}-static
COMPONENT static COMPONENT static
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
# cmake-format: on
endfunction() endfunction()

View File

@ -54,23 +54,23 @@ function(myx_cmake_format_sources target)
endif() endif()
if(EXISTS ${CMAKE_SOURCE_DIR}/.uncrustify.cfg) if(EXISTS ${CMAKE_SOURCE_DIR}/.uncrustify.cfg)
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/uncrustify.cfg add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/uncrustify-${target}.cfg
COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc COMMAND ${UNCRUSTIFY_EXE} --update-config-with-doc
-c ${CMAKE_SOURCE_DIR}/.uncrustify.cfg -c ${CMAKE_SOURCE_DIR}/.uncrustify.cfg
-o ${CMAKE_BINARY_DIR}/uncrustify.cfg) -o ${CMAKE_BINARY_DIR}/uncrustify-${target}.cfg)
list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_BINARY_DIR}/uncrustify.cfg) list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_BINARY_DIR}/uncrustify-${target}.cfg)
endif() endif()
# cmake-format: off # cmake-format: off
add_custom_target(${target}-format-sources-check-uncrustify add_custom_target(${target}-format-sources-check-uncrustify
DEPENDS ${CMAKE_BINARY_DIR}/uncrustify.cfg DEPENDS ${CMAKE_BINARY_DIR}/uncrustify-${target}.cfg
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${__sources}) COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --check ${__sources})
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup) list(APPEND UNCRUSTIFY_OPTS --replace --no-backup)
add_custom_target(${target}-format-sources-uncrustify add_custom_target(${target}-format-sources-uncrustify
DEPENDS ${CMAKE_BINARY_DIR}/uncrustify.cfg DEPENDS ${CMAKE_BINARY_DIR}/uncrustify-${target}.cfg
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${__sources}) COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} --mtime ${__sources})
add_custom_target(${target}-doc-doxygen-append-comments add_custom_target(${target}-doc-doxygen-append-comments
DEPENDS ${CMAKE_BINARY_DIR}/uncrustify.cfg DEPENDS ${CMAKE_BINARY_DIR}/uncrustify-${target}.cfg
COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS} COMMAND ${UNCRUSTIFY_EXE} ${UNCRUSTIFY_OPTS}
--set cmt_insert_class_header=uncrustify-classheader.txt --set cmt_insert_class_header=uncrustify-classheader.txt
--set cmt_insert_file_footer=uncrustify-filefooter.txt --set cmt_insert_file_footer=uncrustify-filefooter.txt