Browse Source

Modern CMake usage: updated FindCorrade.cmake and FindNodeJs.cmake.

pull/142/head
Vladimír Vondruš 10 years ago
parent
commit
08a2a75c5c
  1. 477
      modules/FindCorrade.cmake
  2. 15
      modules/FindNodeJs.cmake

477
modules/FindCorrade.cmake

@ -1,125 +1,188 @@
# - Find Corrade #.rst:
# # Find Corrade
# Basic usage: # ------------
# find_package(Corrade [REQUIRED]) #
# This module tries to find Corrade library and then defines: # Finds the Corrade library. Basic usage::
# CORRADE_FOUND - True if Corrade is found #
# CORRADE_INCLUDE_DIRS - Corrade include directories # find_package(Corrade REQUIRED)
# CORRADE_INTERCONNECT_LIBRARIES - Interconnect library and dependent #
# libraries # This module tries to find the base Corrade library and then defines the
# CORRADE_UTILITY_LIBRARIES - Utility library and dependent # following:
# libraries #
# CORRADE_PLUGINMANAGER_LIBRARIES - PluginManager library and dependent # Corrade_FOUND - Whether the base library was found
# libraries # CORRADE_LIB_SUFFIX_MODULE - Path to CorradeLibSuffix.cmake module
# CORRADE_TESTSUITE_LIBRARIES - TestSuite library and dependent #
# libraries # This command will try to find only the base library, not the optional
# CORRADE_RC_EXECUTABLE - Resource compiler executable # components, which are:
# CORRADE_LIB_SUFFIX_MODULE - Path to CorradeLibSuffix.cmake module #
# Containers - Containers library
# PluginManager - PluginManager library
# TestSuite - TestSuite library
# Utility - Utility library
# rc - corrade-rc executable
#
# Example usage with specifying additional components is::
#
# find_package(Corrade REQUIRED Utility TestSuite)
#
# For each component is then defined:
#
# Corrade_*_FOUND - Whether the component was found
# Corrade::* - Component imported target
#
# The package is found if either debug or release version of each library is # The package is found if either debug or release version of each library is
# found. If both debug and release libraries are found, proper version is # found. If both debug and release libraries are found, proper version is
# chosen based on actual build configuration of the project (i.e. Debug build # chosen based on actual build configuration of the project (i.e. Debug build
# is linked to debug libraries, Release build to release libraries). # is linked to debug libraries, Release build to release libraries).
# #
# Corrade conditionally defines CORRADE_IS_DEBUG_BUILD preprocessor variable in # Corrade conditionally defines ``CORRADE_IS_DEBUG_BUILD`` preprocessor
# case build configuration is Debug (not Corrade itself, but build # variable in case build configuration is ``Debug`` (not Corrade itself, but
# configuration of the project using it). Useful e.g. for selecting proper # build configuration of the project using it). Useful e.g. for selecting
# plugin directory. # proper plugin directory.
# #
# Corrade configures the compiler to use C++11 standard (if it is not already # Corrade defines the following custom target properties:
# configured to do so). Additionally you can use CORRADE_CXX_FLAGS to enable #
# additional pedantic set of warnings and enable hidden visibility by default. # CORRADE_CXX_STANDARD - C++ standard to require when compiling given
# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains
# particular standard setting flag or if given target contains
# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17.
# INTERFACE_CORRADE_CXX_STANDARD - C++ standard to require when using given
# target. Does nothing if :variable:`CMAKE_CXX_FLAGS` already contains
# particular standard setting flag or if given target contains
# :prop_tgt:`CMAKE_CXX_STANDARD` property. Allowed value is 11, 14 or 17.
# CORRADE_USE_PEDANTIC_FLAGS - Enable additional compiler/linker flags.
# Boolean.
#
# These properties are inherited from directory properties, meaning that if you
# set them on directories, they get implicitly set on all targets in given
# directory (with a possibility to do target-specific overrides). All Corrade
# libraries have the :prop_tgt:`INTERFACE_CORRADE_CXX_STANDARD` property set to
# 11, meaning that you will always have at least C++11 enabled once you link to
# any Corrade library.
# #
# Features of found Corrade library are exposed in these variables: # Features of found Corrade library are exposed in these variables:
# CORRADE_GCC47_COMPATIBILITY - Defined if compiled with compatibility #
# mode for GCC 4.7 # CORRADE_GCC47_COMPATIBILITY - Defined if compiled with compatibility mode
# CORRADE_MSVC2015_COMPATIBILITY - Defined if compiled with compatibility # for GCC 4.7
# CORRADE_MSVC2015_COMPATIBILITY - Defined if compiled with compatibility
# mode for MSVC 2015 # mode for MSVC 2015
# CORRADE_BUILD_DEPRECATED - Defined if compiled with deprecated APIs # CORRADE_BUILD_DEPRECATED - Defined if compiled with deprecated APIs
# included # included
# CORRADE_BUILD_STATIC - Defined if compiled as static libraries # CORRADE_BUILD_STATIC - Defined if compiled as static libraries.
# Default are shared libraries.
# CORRADE_TARGET_UNIX - Defined if compiled for some Unix flavor # CORRADE_TARGET_UNIX - Defined if compiled for some Unix flavor
# (Linux, BSD, OS X) # (Linux, BSD, OS X)
# CORRADE_TARGET_APPLE - Defined if compiled for Apple platforms # CORRADE_TARGET_APPLE - Defined if compiled for Apple platforms
# CORRADE_TARGET_IOS - Defined if compiled for iOS # CORRADE_TARGET_IOS - Defined if compiled for iOS
# CORRADE_TARGET_WINDOWS - Defined if compiled for Windows # CORRADE_TARGET_WINDOWS - Defined if compiled for Windows
# CORRADE_TARGET_WINDOWS_RT - Defined if compiled for Windows RT # CORRADE_TARGET_WINDOWS_RT - Defined if compiled for Windows RT
# CORRADE_TARGET_NACL - Defined if compiled for Google Chrome # CORRADE_TARGET_NACL - Defined if compiled for Google Chrome Native
# Native Client # Client
# CORRADE_TARGET_NACL_NEWLIB - Defined if compiled for Google Chrome # CORRADE_TARGET_NACL_NEWLIB - Defined if compiled for Google Chrome Native
# Native Client with `newlib` toolchain # Client with `newlib` toolchain
# CORRADE_TARGET_NACL_GLIBC - Defined if compiled for Google Chrome # CORRADE_TARGET_NACL_GLIBC - Defined if compiled for Google Chrome Native
# Native Client with `glibc` toolchain # Client with `glibc` toolchain
# CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten # CORRADE_TARGET_EMSCRIPTEN - Defined if compiled for Emscripten
# CORRADE_TARGET_ANDROID - Defined if compiled for Android # CORRADE_TARGET_ANDROID - Defined if compiled for Android
# #
# Additionally these variables are defined for internal usage:
#
# CORRADE_INCLUDE_DIR - Root include dir
# CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found
# CORRADE_*_LIBRARY_RELEASE - Release version of given library, if found
# CORRADE_USE_MODULE - Path to UseCorrade.cmake module (included
# automatically)
# CORRADE_TESTSUITE_XCTEST_RUNNER - Path to XCTestRunner.mm.in file
# CORRADE_PEDANTIC_COMPILER_OPTIONS - List of pedantic compiler options used
# for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` enabled
# CORRADE_PEDANTIC_COMPILER_DEFINITIONS - List of pedantic compiler
# definitions used for targets with :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS`
# enabled
#
# Workflows without :prop_tgt:`IMPORTED` targets are deprecated and the
# following variables are included just for backwards compatibility and only if
# :variable:`CORRADE_BUILD_DEPRECATED` is enabled:
#
# CORRADE_*_LIBRARIES - Expands to ``Corrade::*`` target. Use
# ``Corrade::*`` target directly instead.
# CORRADE_CXX_FLAGS - Pedantic compile flags. Use
# :prop_tgt:`CORRADE_USE_PEDANTIC_FLAGS` property instead.
#
# Corrade provides these macros and functions: # Corrade provides these macros and functions:
# #
# .. command:: corrade_add_test
#
# Add unit test using Corrade's TestSuite::
#
# corrade_add_test(<test name>
# <sources>...
# [LIBRARIES <libraries>...])
# #
# Add unit test using Corrade's TestSuite.
# corrade_add_test(test_name
# sources...
# [LIBRARIES libraries...])
# Test name is also executable name. You can also specify libraries to link # Test name is also executable name. You can also specify libraries to link
# with instead of using target_link_libraries(). CORRADE_TESTSUITE_LIBRARIES # with instead of using :command:`target_link_libraries()`.
# are linked automatically to each test. Note that the enable_testing() # ``Corrade::TestSuite`` library is linked automatically to each test. Note
# function must be called explicitly. # that the :command:`enable_testing()` function must be called explicitly.
#
# .. command:: corrade_add_resource
# #
# Compile data resources into application binary::
# #
# Compile data resources into application binary. # corrade_add_resource(<name> <resources.conf>)
# corrade_add_resource(name resources.conf) #
# Depends on corrade-rc, which is part of Corrade utilities. This command # Depends on ``Corrade::rc``, which is part of Corrade utilities. This command
# generates resource data using given configuration file in current build # generates resource data using given configuration file in current build
# directory. Argument name is name under which the resources can be explicitly # directory. Argument name is name under which the resources can be explicitly
# loaded. Variable `name` contains compiled resource filename, which is then # loaded. Variable ``<name>`` contains compiled resource filename, which is
# used for compiling library / executable. Example usage: # then used for compiling library / executable. Example usage::
#
# corrade_add_resource(app_resources resources.conf) # corrade_add_resource(app_resources resources.conf)
# add_executable(app source1 source2 ... ${app_resources}) # add_executable(app source1 source2 ... ${app_resources})
# #
# Add dynamic plugin. # .. command:: corrade_add_plugin
# corrade_add_plugin(plugin_name debug_install_dir release_install_dir
# metadata_file sources...)
# The macro adds preprocessor directive CORRADE_DYNAMIC_PLUGIN. Additional
# libraries can be linked in via target_link_libraries(plugin_name ...). If
# debug_install_dir is set to CMAKE_CURRENT_BINARY_DIR (e.g. for testing
# purposes), the files are copied directly, without the need to perform install
# step. Note that the files are actually put into configuration-based
# subdirectory, i.e. ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}. See
# documentation of CMAKE_CFG_INTDIR variable for more information.
# #
# Add dynamic plugin::
# #
# Add static plugin. # corrade_add_plugin(<plugin name>
# corrade_add_static_plugin(plugin_name install_dir metadata_file # <debug install dir> <release install dir>
# sources...) # <metadata file>
# The macro adds preprocessor directive CORRADE_STATIC_PLUGIN. Additional # <sources>...)
# libraries can be linked in via target_link_libraries(plugin_name ...). If
# install_dir is set to CMAKE_CURRENT_BINARY_DIR (e.g. for testing purposes),
# no installation rules are added.
# #
# Note that plugins built in debug configuration (e.g. with CMAKE_BUILD_TYPE # The macro adds preprocessor directive ``CORRADE_DYNAMIC_PLUGIN``. Additional
# set to Debug) have "-d" suffix to make it possible to have both debug and # libraries can be linked in via :command:`target_link_libraries(plugin_name ...) <target_link_libraries>`.
# release plugins installed alongside each other. # If ``<debug install dir>`` is set to :variable:`CMAKE_CURRENT_BINARY_DIR`
# (e.g. for testing purposes), the files are copied directly, without the need
# to perform install step. Note that the files are actually put into
# configuration-based subdirectory, i.e. ``${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}``.
# See documentation of :variable:`CMAKE_CFG_INTDIR` variable for more
# information.
# #
# .. command:: corrade_add_static_plugin
# #
# Find corresponding DLLs for library files. # Add static plugin::
# corrade_find_dlls_for_libs(<VAR> libs...)
# Available only on Windows, for all *.lib files tries to find corresponding
# DLL file. Useful for bundling dependencies for e.g. WinRT packages.
# #
# corrade_add_static_plugin(<plugin name>
# <install dir>
# <metadata file>
# <sources>...)
# #
# Additionally these variables are defined for internal usage: # The macro adds preprocessor directive ``CORRADE_STATIC_PLUGIN``. Additional
# CORRADE_INCLUDE_DIR - Root include dir # libraries can be linked in via :command:`target_link_libraries(plugin_name ...) <target_link_libraries>`.
# CORRADE_INTERCONNECT_LIBRARY - Interconnect library (w/o # If ``<install dir>`` is set to :variable:`CMAKE_CURRENT_BINARY_DIR` (e.g. for
# dependencies) # testing purposes), no installation rules are added.
# CORRADE_UTILITY_LIBRARY - Utility library (w/o dependencies) #
# CORRADE_PLUGINMANAGER_LIBRARY - Plugin manager library (w/o # Note that plugins built in debug configuration (e.g. with :variable:`CMAKE_BUILD_TYPE`
# dependencies) # set to ``Debug``) have ``"-d"`` suffix to make it possible to have both debug
# CORRADE_TESTSUITE_LIBRARY - TestSuite library (w/o dependencies) # and release plugins installed alongside each other.
# CORRADE_*_LIBRARY_DEBUG - Debug version of given library, if found #
# CORRADE_*_LIBRARY_RELEASE - Release version of given library, if # .. command:: corrade_find_dlls_for_libs
# found #
# CORRADE_USE_MODULE - Path to UseCorrade.cmake module (included # Find corresponding DLLs for library files::
# automatically) #
# CORRADE_TESTSUITE_XCTEST_RUNNER - Path to XCTestRunner.mm.in file # corrade_find_dlls_for_libs(<output variable> <libs>...)
#
# Available only on Windows, for all ``*.lib`` files tries to find
# corresponding DLL file. Useful for bundling dependencies for e.g. WinRT
# packages.
# #
# #
@ -147,45 +210,15 @@
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
# Libraries # Root include dir
foreach(_component Interconnect Utility PluginManager TestSuite)
string(TOUPPER ${_component} _COMPONENT)
# Try to find both debug and release version
find_library(CORRADE_${_COMPONENT}_LIBRARY_DEBUG Corrade${_component}-d)
find_library(CORRADE_${_COMPONENT}_LIBRARY_RELEASE Corrade${_component})
# Set the _LIBRARY variable based on what was found
if(CORRADE_${_COMPONENT}_LIBRARY_DEBUG AND CORRADE_${_COMPONENT}_LIBRARY_RELEASE)
set(CORRADE_${_COMPONENT}_LIBRARY
debug ${CORRADE_${_COMPONENT}_LIBRARY_DEBUG}
optimized ${CORRADE_${_COMPONENT}_LIBRARY_RELEASE})
elseif(CORRADE_${_COMPONENT}_LIBRARY_DEBUG)
set(CORRADE_${_COMPONENT}_LIBRARY ${CORRADE_${_COMPONENT}_LIBRARY_DEBUG})
elseif(CORRADE_${_COMPONENT}_LIBRARY_RELEASE)
set(CORRADE_${_COMPONENT}_LIBRARY ${CORRADE_${_COMPONENT}_LIBRARY_RELEASE})
endif()
mark_as_advanced(CORRADE_${_COMPONENT}_LIBRARY_DEBUG
CORRADE_${_COMPONENT}_LIBRARY_RELEASE
CORRADE_${_COMPONENT}_LIBRARY)
endforeach()
# RC executable
find_program(CORRADE_RC_EXECUTABLE corrade-rc)
# Include dir
find_path(CORRADE_INCLUDE_DIR find_path(CORRADE_INCLUDE_DIR
NAMES Corrade/PluginManager Corrade/Utility) NAMES Corrade/Corrade.h)
mark_as_advanced(CORRADE_INCLUDE_DIR)
# CMake module dir
find_path(_CORRADE_MODULE_DIR
NAMES UseCorrade.cmake CorradeLibSuffix.cmake
PATH_SUFFIXES share/cmake/Corrade)
# Configuration file # Configuration file
find_file(_CORRADE_CONFIGURE_FILE configure.h find_file(_CORRADE_CONFIGURE_FILE configure.h
HINTS ${CORRADE_INCLUDE_DIR}/Corrade/) HINTS ${CORRADE_INCLUDE_DIR}/Corrade/)
mark_as_advanced(_CORRADE_CONFIGURE_FILE)
# We need to open configure.h file from CORRADE_INCLUDE_DIR before we check for # We need to open configure.h file from CORRADE_INCLUDE_DIR before we check for
# the components. Bail out with proper error message if it wasn't found. The # the components. Bail out with proper error message if it wasn't found. The
@ -196,7 +229,7 @@ if(NOT CORRADE_INCLUDE_DIR)
REQUIRED_VARS CORRADE_INCLUDE_DIR _CORRADE_CONFIGURE_FILE) REQUIRED_VARS CORRADE_INCLUDE_DIR _CORRADE_CONFIGURE_FILE)
endif() endif()
# Read flags from fonfiguration # Read flags from configuration
file(READ ${_CORRADE_CONFIGURE_FILE} _corradeConfigure) file(READ ${_CORRADE_CONFIGURE_FILE} _corradeConfigure)
set(_corradeFlags set(_corradeFlags
GCC47_COMPATIBILITY GCC47_COMPATIBILITY
@ -228,46 +261,188 @@ if(CORRADE_TESTSUITE_TARGET_XCTEST)
set(CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED CORRADE_TESTSUITE_XCTEST_RUNNER) set(CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED CORRADE_TESTSUITE_XCTEST_RUNNER)
endif() endif()
include(FindPackageHandleStandardArgs) # CMake module dir
find_package_handle_standard_args(Corrade DEFAULT_MSG find_path(_CORRADE_MODULE_DIR
CORRADE_UTILITY_LIBRARY NAMES UseCorrade.cmake CorradeLibSuffix.cmake
CORRADE_INTERCONNECT_LIBRARY PATH_SUFFIXES share/cmake/Corrade)
CORRADE_PLUGINMANAGER_LIBRARY mark_as_advanced(_CORRADE_MODULE_DIR)
CORRADE_TESTSUITE_LIBRARY
CORRADE_INCLUDE_DIR
CORRADE_RC_EXECUTABLE
_CORRADE_MODULE_DIR
_CORRADE_CONFIGURE_FILE
${CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED})
set(CORRADE_INCLUDE_DIRS ${CORRADE_INCLUDE_DIR})
set(CORRADE_UTILITY_LIBRARIES ${CORRADE_UTILITY_LIBRARY})
set(CORRADE_INTERCONNECT_LIBRARIES ${CORRADE_INTERCONNECT_LIBRARY} ${CORRADE_UTILITY_LIBRARIES})
set(CORRADE_PLUGINMANAGER_LIBRARIES ${CORRADE_PLUGINMANAGER_LIBRARY} ${CORRADE_UTILITY_LIBRARIES})
set(CORRADE_TESTSUITE_LIBRARIES ${CORRADE_TESTSUITE_LIBRARY} ${CORRADE_UTILITY_LIBRARIES})
set(CORRADE_USE_MODULE ${_CORRADE_MODULE_DIR}/UseCorrade.cmake) set(CORRADE_USE_MODULE ${_CORRADE_MODULE_DIR}/UseCorrade.cmake)
set(CORRADE_LIB_SUFFIX_MODULE ${_CORRADE_MODULE_DIR}/CorradeLibSuffix.cmake) set(CORRADE_LIB_SUFFIX_MODULE ${_CORRADE_MODULE_DIR}/CorradeLibSuffix.cmake)
# If the configure file is somewhere else than in root include dir (e.g. when # Ensure that all inter-component dependencies are specified as well
# using CMake subproject), we need to include that dir too foreach(_component ${Corrade_FIND_COMPONENTS})
if(NOT ${CORRADE_INCLUDE_DIR}/Corrade/configure.h STREQUAL ${_CORRADE_CONFIGURE_FILE}) string(TOUPPER ${_component} _COMPONENT)
# Go two levels up
get_filename_component(_CORRADE_CONFIGURE_FILE_INCLUDE_DIR ${_CORRADE_CONFIGURE_FILE} DIRECTORY)
get_filename_component(_CORRADE_CONFIGURE_FILE_INCLUDE_DIR ${_CORRADE_CONFIGURE_FILE_INCLUDE_DIR} DIRECTORY)
list(APPEND CORRADE_INCLUDE_DIRS ${_CORRADE_CONFIGURE_FILE_INCLUDE_DIR})
endif()
# At least static build needs this if(_component STREQUAL Containers)
if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL_GLIBC) set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility)
set(CORRADE_PLUGINMANAGER_LIBRARIES ${CORRADE_PLUGINMANAGER_LIBRARIES} ${CMAKE_DL_LIBS}) elseif(_component STREQUAL Interconnect)
endif() set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility)
elseif(_component STREQUAL PluginManager)
set(_CORRADE_${_COMPONENT}_DEPENDENCIES Containers Utility rc)
elseif(_component STREQUAL TestSuite)
set(_CORRADE_${_COMPONENT}_DEPENDENCIES Utility)
elseif(_component STREQUAL Utility)
set(_CORRADE_${_COMPONENT}_DEPENDENCIES Containers rc)
endif()
# AndroidLogStreamBuffer class needs to be linked to log library list(APPEND _CORRADE_ADDITIONAL_COMPONENTS ${_CORRADE_${_COMPONENT}_DEPENDENCIES})
if(CORRADE_TARGET_ANDROID) endforeach()
set(CORRADE_UTILITY_LIBRARIES ${CORRADE_UTILITY_LIBRARIES} log)
# Join the lists, remove duplicate components
if(_CORRADE_ADDITIONAL_COMPONENTS)
list(INSERT Corrade_FIND_COMPONENTS 0 ${_CORRADE_ADDITIONAL_COMPONENTS})
endif()
if(Corrade_FIND_COMPONENTS)
list(REMOVE_DUPLICATES Corrade_FIND_COMPONENTS)
endif() endif()
mark_as_advanced(_CORRADE_CONFIGURE_FILE _CORRADE_MODULE_DIR) # Component distinction
set(_CORRADE_LIBRARY_COMPONENTS "^(Containers|Interconnect|PluginManager|TestSuite|Utility)$")
set(_CORRADE_HEADER_ONLY_COMPONENTS "^(Containers)$")
set(_CORRADE_EXECUTABLE_COMPONENTS "^(rc)$")
# Find all components
foreach(_component ${Corrade_FIND_COMPONENTS})
string(TOUPPER ${_component} _COMPONENT)
# Create imported target in case the library is found. If the project is
# added as subproject to CMake, the target already exists and all the
# required setup is already done from the build tree.
if(TARGET Corrade::${_component})
set(Corrade_${_component}_FOUND TRUE)
else()
# Library components
if(_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND NOT _component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS})
add_library(Corrade::${_component} UNKNOWN IMPORTED)
# Try to find both debug and release version
find_library(CORRADE_${_COMPONENT}_LIBRARY_DEBUG Corrade${_component}-d)
find_library(CORRADE_${_COMPONENT}_LIBRARY_RELEASE Corrade${_component})
mark_as_advanced(CORRADE_${_COMPONENT}_LIBRARY_DEBUG
CORRADE_${_COMPONENT}_LIBRARY_RELEASE)
if(CORRADE_${_COMPONENT}_LIBRARY_RELEASE)
set_property(TARGET Corrade::${_component} APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_property(TARGET Corrade::${_component} PROPERTY
IMPORTED_LOCATION_RELEASE ${CORRADE_${_COMPONENT}_LIBRARY_RELEASE})
endif()
if(CORRADE_${_COMPONENT}_LIBRARY_DEBUG)
set_property(TARGET Corrade::${_component} APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_property(TARGET Corrade::${_component} PROPERTY
IMPORTED_LOCATION_DEBUG ${CORRADE_${_COMPONENT}_LIBRARY_DEBUG})
endif()
endif()
# Header-only library components (CMake >= 3.0)
if(_component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS} AND NOT CMAKE_VERSION VERSION_LESS 3.0.0)
add_library(Corrade::${_component} INTERFACE IMPORTED)
endif()
# Executable components
if(_component MATCHES ${_CORRADE_EXECUTABLE_COMPONENTS})
add_executable(Corrade::${_component} IMPORTED)
find_program(CORRADE_${_COMPONENT}_EXECUTABLE corrade-${_component})
mark_as_advanced(CORRADE_${_COMPONENT}_EXECUTABLE)
if(CORRADE_${_COMPONENT}_EXECUTABLE)
set_property(TARGET Corrade::${_component} PROPERTY
IMPORTED_LOCATION ${CORRADE_${_COMPONENT}_EXECUTABLE})
endif()
endif()
# No special setup for Containers library
# No special setup for Interconnect library
# PluginManager library
if(_component STREQUAL PluginManager)
# At least static build needs this
if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_NACL_GLIBC)
set_property(TARGET Corrade::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS})
endif()
# No special setup for TestSuite library
# Utility library (contains all setup that is used by others)
elseif(_component STREQUAL Utility)
# Top-level include directory
set_property(TARGET Corrade::${_component} APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${CORRADE_INCLUDE_DIR})
# Require (at least) C++11 for users
if(NOT CMAKE_VERSION VERSION_LESS 3.0.0)
set_property(TARGET Corrade::${_component} PROPERTY
INTERFACE_CORRADE_CXX_STANDARD 11)
set_property(TARGET Corrade::${_component} APPEND PROPERTY
COMPATIBLE_INTERFACE_NUMBER_MAX CORRADE_CXX_STANDARD)
else()
# 2.8.12 is fucking buggy shit. Besides the fact that it
# doesn't know COMPATIBLE_INTERFACE_NUMBER_MAX, if I
# define_property() so I can inherit it from directory on a
# target, then I can't use it in COMPATIBLE_INTERFACE_STRING
# to inherit it from interfaces BECAUSE!! it thinks that it is
# not an user-defined property anymore. So I need to have two
# sets of properties, CORRADE_CXX_STANDARD_ used silently for
# inheritance from interfaces and CORRADE_CXX_STANDARD used
# publicly for inheritance from directories. AAAAAAAAARGH.
set_property(TARGET Corrade::${_component} PROPERTY
INTERFACE_CORRADE_CXX_STANDARD_ 11)
set_property(TARGET Corrade::${_component} APPEND PROPERTY
COMPATIBLE_INTERFACE_STRING CORRADE_CXX_STANDARD_)
endif()
# AndroidLogStreamBuffer class needs to be linked to log library
if(CORRADE_TARGET_ANDROID)
set_property(TARGET Corrade::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES "log")
endif()
endif()
# Find library includes
if(_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS})
find_path(_CORRADE_${_COMPONENT}_INCLUDE_DIR
NAMES ${_component}.h
HINTS ${CORRADE_INCLUDE_DIR}/Corrade/${_component})
mark_as_advanced(_CORRADE_${_COMPONENT}_INCLUDE_DIR)
endif()
# Add inter-library dependencies (except for the header-only libraries
# on 2.8.12)
if(_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND (NOT CMAKE_VERSION VERSION_LESS 3.0.0 OR NOT _component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS}))
foreach(_dependency ${_CORRADE_${_COMPONENT}_DEPENDENCIES})
if(_dependency MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND (NOT CMAKE_VERSION VERSION_LESS 3.0.0 OR NOT _dependency MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS}))
set_property(TARGET Corrade::${_component} APPEND PROPERTY
INTERFACE_LINK_LIBRARIES Corrade::${_dependency})
endif()
endforeach()
endif()
# Decide if the component was found
if((_component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND _CORRADE_${_COMPONENT}_INCLUDE_DIR AND (_component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS} OR CORRADE_${_COMPONENT}_LIBRARY_RELEASE OR CORRADE_${_COMPONENT}_LIBRARY_DEBUG)) OR (_component MATCHES ${_CORRADE_EXECUTABLE_COMPONENTS} AND CORRADE_${_COMPONENT}_EXECUTABLE))
set(Corrade_${_component}_FOUND TRUE)
else()
set(Corrade_${_component}_FOUND FALSE)
endif()
endif()
# Deprecated variables
if(CORRADE_BUILD_DEPRECATED AND _component MATCHES ${_CORRADE_LIBRARY_COMPONENTS} AND NOT _component MATCHES ${_CORRADE_HEADER_ONLY_COMPONENTS})
set(CORRADE_${_COMPONENT}_LIBRARIES Corrade::${_component})
endif()
endforeach()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Corrade REQUIRED_VARS
CORRADE_INCLUDE_DIR
_CORRADE_MODULE_DIR
_CORRADE_CONFIGURE_FILE
${CORRADE_TESTSUITE_XCTEST_RUNNER_NEEDED}
HANDLE_COMPONENTS)
# Finalize the finding process # Finalize the finding process
include(${CORRADE_USE_MODULE}) include(${CORRADE_USE_MODULE})

15
modules/FindNodeJs.cmake

@ -1,15 +1,17 @@
# - Find Node.js #.rst:
# Find Node.js
# ------------
# #
# This module defines: # Finds the Node.js executable. This module defines:
# #
# NODEJS_FOUND - True if Node.js executable is found # NODEJS_FOUND - True if Node.js executable is found
# NODEJS_EXECUTABLE - Node.js executable # NodeJs::NodeJs - Node.js executable imported target
# #
# #
# This file is part of Corrade. # This file is part of Corrade.
# #
# Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013 # Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
# Vladimír Vondruš <mosra@centrum.cz> # Vladimír Vondruš <mosra@centrum.cz>
# #
# Permission is hereby granted, free of charge, to any person obtaining a # Permission is hereby granted, free of charge, to any person obtaining a
@ -35,3 +37,8 @@ find_program(NODEJS_EXECUTABLE node)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("NodeJs" DEFAULT_MSG NODEJS_EXECUTABLE) find_package_handle_standard_args("NodeJs" DEFAULT_MSG NODEJS_EXECUTABLE)
if(NOT TARGET NodeJs::NodeJs)
add_executable(NodeJs::NodeJs IMPORTED)
set_property(TARGET NodeJs::NodeJs PROPERTY IMPORTED_LOCATION ${NODEJS_EXECUTABLE})
endif()

Loading…
Cancel
Save