diff --git a/CMakeLists.txt b/CMakeLists.txt index ba45986..2456e94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.0) -project(myx-cmake VERSION 0.2.0 LANGUAGES) +project(myx-cmake VERSION 0.2.4 LANGUAGES) include(GNUInstallDirs) file(WRITE ${CMAKE_SOURCE_DIR}/MyxCMake/MyxCMakeConfigVersion.cmake diff --git a/MyxCMake/modules/MyxCMakePkgConfig.cmake b/MyxCMake/modules/MyxCMakePkgConfig.cmake index 0702b1f..08d8597 100644 --- a/MyxCMake/modules/MyxCMakePkgConfig.cmake +++ b/MyxCMake/modules/MyxCMakePkgConfig.cmake @@ -1,39 +1,42 @@ function(myx_cmake_generate_pkgconfig target) set(options) - set(oneVA COMPONENT) + set(oneVA COMPONENT BASENAME) set(multiVA) cmake_parse_arguments(ARG "${options}" "${oneVA}" "${multiVA}" ${ARGN}) + if(NOT ARG_BASENAME) + set(ARG_BASENAME ${target}) + endif() + if(NOT ARG_COMPONENT) set(ARG_COMPONENT dev) endif() - get_target_property(_target_type ${target} TYPE) - - if(_target_type STREQUAL INTERFACE_LIBRARY) + get_target_property(__target_type ${target} TYPE) + if(__target_type STREQUAL INTERFACE_LIBRARY) file( - WRITE "${CMAKE_BINARY_DIR}/${target}.pc" + WRITE "${CMAKE_BINARY_DIR}/${BASENAME}.pc" "prefix=${CMAKE_INSTALL_PREFIX}\n" "exec_prefix=${CMAKE_INSTALL_PREFIX}\n" "includedir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n" "\n" - "Name: ${target}\n" - "Description: ${target} header-only library\n" + "Name: ${BASENAME}\n" + "Description: ${BASENAME} header-only library\n" "Version: ${PROJECT_VERSION}\n" "\n" "Requires:\n" "Cflags: -I${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n") else() file( - WRITE "${CMAKE_BINARY_DIR}/${target}.pc" + WRITE "${CMAKE_BINARY_DIR}/${BASENAME}.pc" "prefix=${CMAKE_INSTALL_PREFIX}\n" "exec_prefix=${CMAKE_INSTALL_PREFIX}\n" "libdir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}\n" "includedir=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n" "\n" - "Name: ${target}\n" - "Description: ${target} library\n" + "Name: ${BASENAME}\n" + "Description: ${BASENAME} library\n" "Version: ${PROJECT_VERSION}\n" "\n" "Requires:\n" @@ -41,7 +44,7 @@ function(myx_cmake_generate_pkgconfig target) "Cflags: -I${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}\n") endif() install( - FILES "${CMAKE_BINARY_DIR}/${target}.pc" + FILES "${CMAKE_BINARY_DIR}/${BASENAME}.pc" COMPONENT ${ARG_COMPONENT} DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endfunction()