view cmake/function/MalikaniaDefineLibrary.cmake @ 215:268b66d72ec0 default tip @

misc: remove Javascript bindings, closes #2402
author David Demelier <markand@malikania.fr>
date Thu, 10 Oct 2019 13:52:57 +0200
parents c973501abe36
children
line wrap: on
line source

#
# MalikaniaDefineLibrary.cmake -- CMake build system for malikania
#
# Copyright (c) 2013-2018 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.
#

#
# malikania_define_library
# ------------------------
#
# malikania_define_library(
#       TARGET                  The target name
#       SOURCES                 The sources
#       ASSETS                  (Optional) Additional assets files
#       INTERFACE_FLAGS         (Optional) List of interface flags
#       PRIVATE_FLAGS           (Optional) list of private flags
#       PUBLIC_FLAGS            (Optional) list of public flags
#       INTERFACE_INCLUDES      (Optional) List of interface include directories
#       INTERFACE_LIBRARIES     (Optional) List of interface libraries
#       PRIVATE_INCLUDES        (Optional) List of private include directories
#       PRIVATE_LIBRARIES       (Optional) List of private libraries
#       PUBLIC_INCLUDES         (Optional) List of public include directories
#       PUBLIC_LIBRARIES        (Optional) List of public libraries
# )
#
# Create a library and install it.
#

include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaBuildAssets.cmake)

function(malikania_define_library)
	set(singleArgs TARGET)
	set(
		multiArgs
		ASSETS
		INTERFACE_FLAGS
		INTERFACE_INCLUDES
		INTERFACE_LIBRARIES
		PRIVATE_FLAGS
		PRIVATE_INCLUDES
		PRIVATE_LIBRARIES
		PUBLIC_FLAGS
		PUBLIC_INCLUDES
		PUBLIC_LIBRARIES
		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} ${LIB_ASSETS})
	target_link_libraries(
		${LIB_TARGET}
		PRIVATE ${LIB_PRIVATE_LIBRARIES}
		PUBLIC ${LIB_PUBLIC_LIBRARIES}
		INTERFACE ${LIB_INTERFACE_LIBRARIES}
	)
	target_include_directories(
		${LIB_TARGET}
		PRIVATE
			${CMAKE_CURRENT_BINARY_DIR}
			${LIB_PRIVATE_INCLUDES}
		PUBLIC ${LIB_PUBLIC_INCLUDES}
		INTERFACE ${LIB_INTERFACE_INCLUDES}
	)
	target_compile_definitions(
		${LIB_TARGET}
		PRIVATE ${LIB_PRIVATE_FLAGS}
		PUBLIC ${LIB_PUBLIC_FLAGS}
		INTERFACE ${LIB_INTERFACE_FLAGS}
	)
	set_target_properties(
		${LIB_TARGET}
		PROPERTIES
			PREFIX ""
			IMPORT_PREFIX ""
	)
endfunction()