Mercurial > irccd
view cmake/function/IrccdDefineLibrary.cmake @ 874:bf2bdb41f181
doc: improve doxygen documentation
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 15 Aug 2019 19:47:53 +0200 |
parents | 6af323b76970 |
children | 6baa070e083c |
line wrap: on
line source
# # IrccdDefineLibrary.cmake -- CMake build system for irccd # # Copyright (c) 2013-2019 David Demelier <markand@malikania.fr> # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. # # # irccd_define_library # -------------------- # # Synopsis: # # irccd_define_library( # TARGET target name # SOURCES src1, src2, srcn # EXPORT (Optional) set to true to export library through irccd # and install it # HEADERS (Optional) directory of headers to install # FLAGS (Optional) C/C++ flags (without -D) # LIBRARIES (Optional) libraries to link # LOCAL_INCLUDES (Optional) local includes for the target only # PUBLIC_INCLUDES (Optional) includes to share with target dependencies # ) # # Create a library and optionally install it. # # The function create a new library named with the parameter TARGET, you should # prefix it with "lib" as its the convention within irccd (e.g. libfoo), the # prefix is automatically removed. # # The argument SOURCES should contains the C++ source files and HEADERS should # points to a directory to be installed verbatim in the include directory. # # Optional argument FLAGS, LOCAL_INCLUDES, PUBLIC_INCLUDES, LIBRARIES may be # passed to set compile flags, private includes, public includes and libraries # respectively. # # If export boolean parameter is set, the library is exported and installed. # include(${CMAKE_CURRENT_LIST_DIR}/IrccdInstallDependencies.cmake) function(irccd_define_library) set(options EXPORT) set(oneValueArgs TARGET) set(multiValueArgs HEADERS SOURCES FLAGS LIBRARIES LOCAL_INCLUDES PUBLIC_INCLUDES) cmake_parse_arguments(LIB "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if (NOT LIB_TARGET) message(FATAL_ERROR "Please set TARGET") endif () if (NOT LIB_SOURCES) message(FATAL_ERROR "Please set SOURCES") endif () add_library(${LIB_TARGET} ${LIB_SOURCES} ${LIB_HEADERS}) target_include_directories( ${LIB_TARGET} PRIVATE ${LIB_LOCAL_INCLUDES} PUBLIC ${LIB_PUBLIC_INCLUDES} ) target_compile_definitions( ${LIB_TARGET} PRIVATE CMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}" CMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}" PUBLIC ${LIB_FLAGS} ) target_link_libraries(${LIB_TARGET} ${LIB_LIBRARIES}) set_target_properties( ${LIB_TARGET} PROPERTIES PREFIX "" IMPORT_PREFIX "" CXX_STANDARD 17 CXX_STANDARD_REQUIRED On ) if (${LIB_EXPORT}) install( TARGETS ${LIB_TARGET} EXPORT irccd-targets RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) irccd_install_dependencies(${LIB_TARGET}) endif () if (LIB_HEADERS) install( DIRECTORY ${LIB_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/irccd ) endif () endfunction()