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)
project(myx-cmake VERSION 0.4.4 LANGUAGES)
project(myx-cmake VERSION 0.4.5 LANGUAGES)
include(GNUInstallDirs)
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")
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}>)
set_target_properties(
${target}-shared
PROPERTIES OUTPUT_NAME ${target}
# cmake-format: off
set_target_properties(${target}-shared
PROPERTIES OUTPUT_NAME ${__output_name}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
LIBRARY_OUTPUT_DIRECTORY
@ -21,4 +26,5 @@ function(myx_cmake_add_shared_library target)
install(TARGETS ${target}-shared
COMPONENT main
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
# cmake-format: on
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")
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}>)
# cmake-format: off
set_target_properties(${target}-static
PROPERTIES
OUTPUT_NAME ${target}
PROPERTIES OUTPUT_NAME ${__output_name}
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${target}-static
COMPONENT static
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
# cmake-format: on
endfunction()

View File

@ -54,23 +54,23 @@ function(myx_cmake_format_sources target)
endif()
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
-c ${CMAKE_SOURCE_DIR}/.uncrustify.cfg
-o ${CMAKE_BINARY_DIR}/uncrustify.cfg)
list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_BINARY_DIR}/uncrustify.cfg)
-o ${CMAKE_BINARY_DIR}/uncrustify-${target}.cfg)
list(APPEND UNCRUSTIFY_OPTS -c ${CMAKE_BINARY_DIR}/uncrustify-${target}.cfg)
endif()
# cmake-format: off
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})
list(APPEND UNCRUSTIFY_OPTS --replace --no-backup)
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})
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}
--set cmt_insert_class_header=uncrustify-classheader.txt
--set cmt_insert_file_footer=uncrustify-filefooter.txt