Browse Source

CMake subproject support, part 3: ability to override configure.h location.

Similarly as in Corrade, but this did not require any user-facing
changes.
pull/126/head
Vladimír Vondruš 11 years ago
parent
commit
c8a9417e70
  1. 20
      modules/FindMagnum.cmake

20
modules/FindMagnum.cmake

@ -180,17 +180,21 @@ endif()
find_path(MAGNUM_INCLUDE_DIR find_path(MAGNUM_INCLUDE_DIR
NAMES Magnum/Magnum.h) NAMES Magnum/Magnum.h)
# Configuration file
find_file(_MAGNUM_CONFIGURE_FILE configure.h
HINTS ${MAGNUM_INCLUDE_DIR}/Magnum/)
# We need to open configure.h file from MAGNUM_INCLUDE_DIR before we check for # We need to open configure.h file from MAGNUM_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
# complete check with all components is further below. # complete check with all components is further below.
if(NOT MAGNUM_INCLUDE_DIR) if(NOT MAGNUM_INCLUDE_DIR)
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Magnum find_package_handle_standard_args(Magnum
REQUIRED_VARS MAGNUM_LIBRARY MAGNUM_INCLUDE_DIR) REQUIRED_VARS MAGNUM_LIBRARY MAGNUM_INCLUDE_DIR _MAGNUM_CONFIGURE_FILE)
endif() endif()
# Configuration # Configuration
file(READ ${MAGNUM_INCLUDE_DIR}/Magnum/configure.h _magnumConfigure) file(READ ${_MAGNUM_CONFIGURE_FILE} _magnumConfigure)
set(_magnumFlags set(_magnumFlags
BUILD_DEPRECATED BUILD_DEPRECATED
BUILD_STATIC BUILD_STATIC
@ -224,6 +228,15 @@ elseif(MAGNUM_TARGET_GLES3)
set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} ${OPENGLES3_LIBRARY}) set(MAGNUM_LIBRARIES ${MAGNUM_LIBRARIES} ${OPENGLES3_LIBRARY})
endif() endif()
# If the configure file is somewhere else than in root include dir (e.g. when
# using CMake subproject), we need to include that dir too
if(NOT ${MAGNUM_INCLUDE_DIR}/Magnum/configure.h STREQUAL ${_MAGNUM_CONFIGURE_FILE})
# Go two levels up
get_filename_component(_MAGNUM_CONFIGURE_FILE_INCLUDE_DIR ${_MAGNUM_CONFIGURE_FILE} DIRECTORY)
get_filename_component(_MAGNUM_CONFIGURE_FILE_INCLUDE_DIR ${_MAGNUM_CONFIGURE_FILE_INCLUDE_DIR} DIRECTORY)
list(APPEND MAGNUM_INCLUDE_DIRS ${_MAGNUM_CONFIGURE_FILE_INCLUDE_DIR})
endif()
# Emscripten needs special flag to use WebGL 2 # Emscripten needs special flag to use WebGL 2
if(CORRADE_TARGET_EMSCRIPTEN AND NOT MAGNUM_TARGET_GLES2 AND NOT CMAKE_EXE_LINKER_FLAGS MATCHES "USE_WEBGL2") if(CORRADE_TARGET_EMSCRIPTEN AND NOT MAGNUM_TARGET_GLES2 AND NOT CMAKE_EXE_LINKER_FLAGS MATCHES "USE_WEBGL2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_WEBGL2=1") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_WEBGL2=1")
@ -623,7 +636,8 @@ mark_as_advanced(FORCE
MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_INSTALL_DIR MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_INSTALL_DIR
MAGNUM_CMAKE_MODULE_INSTALL_DIR MAGNUM_CMAKE_MODULE_INSTALL_DIR
MAGNUM_INCLUDE_INSTALL_DIR MAGNUM_INCLUDE_INSTALL_DIR
MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR) MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR
_MAGNUM_CONFIGURE_FILE)
# Get base plugin directory from main library location # Get base plugin directory from main library location
set(MAGNUM_PLUGINS_DEBUG_DIR ${_MAGNUM_LIBRARY_PATH}/magnum-d set(MAGNUM_PLUGINS_DEBUG_DIR ${_MAGNUM_LIBRARY_PATH}/magnum-d

Loading…
Cancel
Save