Mercurial > malikania
view cmake/function/MalikaniaDefineLibrary.cmake @ 76:858621081b95
Happy new year!
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 01 Jan 2017 13:35:37 +0100 |
parents | 0a1e3bb3c629 |
children | 119bcc5a727e |
line wrap: on
line source
# # MalikaniaDefineLibrary.cmake -- CMake build system for malikania # # Copyright (c) 2013-2017 Malikania Authors # # 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. # # # malikania_define_library # ------------------------ # # malikania_define_library( # TARGET The target name # SOURCES The sources # ASSETS (Optional) Additional assets files # FLAGS (Optional) List of flags # PRIVATE_INCLUDES (Optional) List of includes only for building the library # PUBLIC_INCLUDES (Optional) List of public includes to share with the library users # LIBRARIES (Optional) List of libraries to link against # ) # # Create a shared library. Follow the same specification as malikania_define_executable. # However, additional PRIVATE_INCLUDES and PUBLIC_INCLUDES are available. # include(CMakeParseArguments) include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaBuildAssets.cmake) include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaVeraCheck.cmake) function(malikania_define_library) set(singleArgs TARGET) set(multiArgs ASSETS SOURCES FLAGS PRIVATE_INCLUDES PUBLIC_INCLUDES LIBRARIES) set(mandatory TARGET SOURCES) cmake_parse_arguments(LIB "" "${singleArgs}" "${multiArgs}" ${ARGN}) if (NOT LIB_TARGET) message(FATAL_ERROR "Missing TARGET parameter") endif () if (NOT LIB_SOURCES) message(FATAL_ERROR "Missing SOURCES parameter") endif () # Enable assets for libraries. malikania_build_assets("${LIB_ASSETS}" assets) # Create the shared library. add_library(${LIB_TARGET} SHARED ${LIB_SOURCES} ${assets}) target_link_libraries(${LIB_TARGET} ${LIB_LIBRARIES}) target_include_directories( ${LIB_TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/assets ${LIB_PRIVATE_INCLUDES} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${LIB_PUBLIC_INCLUDES} ) target_compile_definitions(${LIB_TARGET} PRIVATE ${LIB_FLAGS}) # # Move the library into fakeroot/bin/ directory for Windows and other # DLL platforms so executables can be ran directly. # set_target_properties( ${LIB_TARGET} PROPERTIES PREFIX "" RUNTIME_OUTPUT_DIRECTORY ${WITH_FAKEROOT_DIR}/bin ) foreach (cfg ${CMAKE_CONFIGURATION_TYPES}) string(TOUPPER ${cfg} cfg) set_target_properties( ${LIB_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${cfg} ${WITH_FAKEROOT_DIR}/bin ) endforeach () malikania_vera_check(${LIB_TARGET} "${LIB_SOURCES}") endfunction()