CMake: fix calamares_add_library
- Remove the commented-out cruft and the whinging - Fix use of COMPILE_DEFINITIONS with a list passed in - Remove unused arguments (TYPE, TARGET) - Document calamares_add_library - Document how to use COMPILE_DEFINITIONS (in calamares_add_plugin)
This commit is contained in:
parent
e71fa5963b
commit
d7594860b0
@ -19,27 +19,41 @@
|
|||||||
###
|
###
|
||||||
#
|
#
|
||||||
# Support functions for building plugins.
|
# Support functions for building plugins.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
#
|
||||||
|
# calamares_add_library(
|
||||||
|
# library-name
|
||||||
|
# EXPORT_MACRO macro-name
|
||||||
|
# TARGET_TYPE <STATIC|MODULE|...>
|
||||||
|
# EXPORT export-name
|
||||||
|
# VERSION version
|
||||||
|
# SOVERSION version
|
||||||
|
# INSTALL_BINDIR dir
|
||||||
|
# RESOURCES resource-file
|
||||||
|
# SOURCES source-file...
|
||||||
|
# UI ui-file...
|
||||||
|
# LINK_LIBRARIES lib...
|
||||||
|
# LINK_PRIVATE_LIBRARIES lib...
|
||||||
|
# COMPILE_DEFINITIONS def...
|
||||||
|
# [NO_INSTALL]
|
||||||
|
# [NO_VERSION]
|
||||||
|
# )
|
||||||
|
#
|
||||||
|
# The COMPILE_DEFINITIONS are set on the resulting module with a suitable
|
||||||
|
# flag (i.e. `-D`) so only state the name (optionally, also the value)
|
||||||
|
# without a `-D` prefixed to it. Pass in a CMake list as needed.
|
||||||
include( CMakeParseArguments )
|
include( CMakeParseArguments )
|
||||||
|
|
||||||
function(calamares_add_library)
|
function(calamares_add_library)
|
||||||
# parse arguments (name needs to be saved before passing ARGN into the macro)
|
# parse arguments (name needs to be saved before passing ARGN into the macro)
|
||||||
set(NAME ${ARGV0})
|
set(NAME ${ARGV0})
|
||||||
set(options NO_INSTALL NO_VERSION)
|
set(options NO_INSTALL NO_VERSION)
|
||||||
set(oneValueArgs NAME TYPE EXPORT_MACRO TARGET TARGET_TYPE EXPORT VERSION SOVERSION INSTALL_BINDIR RESOURCES)
|
set(oneValueArgs NAME EXPORT_MACRO TARGET_TYPE EXPORT VERSION SOVERSION INSTALL_BINDIR RESOURCES)
|
||||||
set(multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS QT5_MODULES)
|
set(multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS)
|
||||||
cmake_parse_arguments(LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
cmake_parse_arguments(LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
set(LIBRARY_NAME ${NAME})
|
set(LIBRARY_NAME ${NAME})
|
||||||
|
|
||||||
|
|
||||||
# message("*** Arguments for ${LIBRARY_NAME}")
|
|
||||||
# message("Sources: ${LIBRARY_SOURCES}")
|
|
||||||
# message("Link libraries: ${LIBRARY_LINK_LIBRARIES}")
|
|
||||||
# message("UI: ${LIBRARY_UI}")
|
|
||||||
# message("TARGET_TYPE: ${LIBRARY_TARGET_TYPE}")
|
|
||||||
# message("EXPORT_MACRO: ${LIBRARY_EXPORT_MACRO}")
|
|
||||||
# message("NO_INSTALL: ${LIBRARY_NO_INSTALL}")
|
|
||||||
|
|
||||||
set(target ${LIBRARY_NAME})
|
set(target ${LIBRARY_NAME})
|
||||||
|
|
||||||
# qt stuff
|
# qt stuff
|
||||||
@ -76,13 +90,8 @@ function(calamares_add_library)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LIBRARY_COMPILE_DEFINITIONS)
|
if(LIBRARY_COMPILE_DEFINITIONS)
|
||||||
# Dear CMake, i hate you! Sincerely, domme
|
set( _lib_definitions "${LIBRARY_EXPORT_MACRO}" ${LIBRARY_COMPILE_DEFINITIONS} )
|
||||||
# At least in CMake 2.8.8, you CANNOT set more than one COMPILE_DEFINITIONS value
|
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS "${_lib_definitions}")
|
||||||
# only takes the first one if called multiple times or bails out with wrong number of arguments
|
|
||||||
# when passing in a list, thus i redefine the export macro here in hope it won't mess up other targets
|
|
||||||
add_definitions( "-D${LIBRARY_EXPORT_MACRO}" )
|
|
||||||
|
|
||||||
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_COMPILE_DEFINITIONS})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# add link targets
|
# add link targets
|
||||||
@ -119,9 +128,6 @@ function(calamares_add_library)
|
|||||||
set(LIBRARY_INSTALL_LIBDIR "${LIBRARY_INSTALL_BINDIR}")
|
set(LIBRARY_INSTALL_LIBDIR "${LIBRARY_INSTALL_BINDIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#message("INSTALL_BINDIR: ${LIBRARY_INSTALL_BINDIR}")
|
|
||||||
#message("INSTALL_LIBDIR: ${LIBRARY_INSTALL_LIBDIR}")
|
|
||||||
|
|
||||||
# make installation optional, maybe useful for dummy plugins one day
|
# make installation optional, maybe useful for dummy plugins one day
|
||||||
if(NOT LIBRARY_NO_INSTALL)
|
if(NOT LIBRARY_NO_INSTALL)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
@ -40,6 +40,10 @@
|
|||||||
# [SHARED_LIB]
|
# [SHARED_LIB]
|
||||||
# [EMERGENCY]
|
# [EMERGENCY]
|
||||||
# )
|
# )
|
||||||
|
#
|
||||||
|
# The COMPILE_DEFINITIONS are set on the resulting module with a suitable
|
||||||
|
# flag (i.e. `-D`) so only state the name (optionally, also the value)
|
||||||
|
# without a `-D` prefixed to it.
|
||||||
|
|
||||||
include( CMakeParseArguments )
|
include( CMakeParseArguments )
|
||||||
include( CalamaresAddLibrary )
|
include( CalamaresAddLibrary )
|
||||||
|
Loading…
Reference in New Issue
Block a user