Created
June 26, 2014 15:59
-
-
Save bo0ts/8adb114325a18354f604 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#.rst: | |
# FindLEDA | |
# ---------- | |
# | |
# FindModule for LEDA. | |
# | |
# IMPORTED Targets | |
# ^^^^^^^^^^^^^^^^ | |
# | |
# This module defines the :prop_tgt:`IMPORTED` target ``LEDA::LEDA``, | |
# if LEDA is found. | |
# | |
# Result Variables | |
# ^^^^^^^^^^^^^^^^ | |
# | |
# This module sets the following variables: | |
# | |
# ``LEDA_FOUND`` | |
# True, if the system has LEDA. | |
# ``LEDA_INCLUDE_DIR`` | |
# Path to the LEDA include directory. | |
# ``LEDA_LIBRARIES`` | |
# Paths to the LEDA libraries. | |
# ``LEDA_LIBRARY_DEBUG`` | |
# Path to the debug version of the library, if found. | |
# ``LEDA_LIBRARY_RELEASE`` | |
# Path to the release version of the library, if found. | |
# | |
# Search Variables | |
# ^^^^^^^^^^^^^^^^ | |
# | |
# ``LEDA_ROOT`` | |
# Can be set to the root of a LEDA directory. If not set, | |
# the environment variable LEDA_DIR is used to initialize it. | |
# ``LEDA_INC_DIR`` | |
# Environment variable used as a hint for the include directory. | |
# ``LEDA_LIB_DIR`` | |
# Environment variable used as a hint for the library path. | |
if(NOT LEDA_ROOT) | |
set(LEDA_ROOT $ENV{LEDA_DIR}) | |
endif() | |
find_path(LEDA_INCLUDE_DIR | |
NAMES "LEDA/basic.h" "LEDA/system/basic.h" | |
HINTS "${LEDA_ROOT}" ENV LEDA_INC_DIR | |
PATH_SUFFIXES incl | |
DOC "The directory containing the LEDA header files WITHOUT the LEDA prefix" | |
) | |
message(${LEDA_INCLUDE_DIR}) | |
find_library(LEDA_LIBRARY_RELEASE NAMES "leda" | |
HINTS "${LEDA_ROOT}" ENV LEDA_LIB_DIR | |
DOC "Path to the LEDA library") | |
find_library(LEDA_LIBRARY_DEBUG NAMES "ledaD" | |
HINTS "${LEDA_ROOT}" ENV LEDA_LIB_DIR | |
DOC "Path to the LEDA library") | |
if(LEDA_LIBRARY_RELEASE) | |
if(LEDA_LIBRARY_DEBUG) | |
set(LEDA_LIBRARIES optimized ${LEDA_LIBRARY_RELEASE} debug ${LEDA_LIBRARY_DEBUG}) | |
else() | |
set(LEDA_LIBRARIES ${LEDA_LIBRARY_RELEASE}) | |
endif() | |
endif() | |
set(LEDA_BASIC_H "${LEDA_INCLUDE_DIR}/LEDA/system/basic.h") | |
if(NOT EXISTS ${LEDA_BASIC_H}) | |
set(LEDA_BASIC_H "${LEDA_INCLUDE_DIR}/LEDA/basic.h") | |
endif() | |
if(EXISTS ${LEDA_BASIC_H}) | |
file(READ "${LEDA_BASIC_H}" LEDA_BASIC_H_CONTENTS) | |
string(REGEX REPLACE ".*#define __LEDA__ ([0-9]+).*" "\\1" LEDA_VERSION_STRING "${LEDA_BASIC_H_CONTENTS}") | |
endif() | |
include(FindPackageHandleStandardArgs) | |
find_package_handle_standard_args(LEDA FOUND_VAR LEDA_FOUND | |
REQUIRED_VARS LEDA_INCLUDE_DIR LEDA_LIBRARIES VERSION_VAR LEDA_VERSION_STRING) | |
if(LEDA_FOUND) | |
# Handwriting the CompilerOptions target here is fine since it is an | |
# imported target. Otherwise we would need generator expressions. | |
if(NOT TARGET LEDA::CompilerOptions) | |
add_library(LEDA::CompilerOptions INTERFACE IMPORTED) | |
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | |
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.1") | |
set_property(TARGET LEDA::CompilerOptions APPEND | |
PROPERTY INTERFACE_COMPILE_OPTIONS "-ffriend-injection") | |
endif() | |
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.1") | |
set_property(TARGET LEDA::CompilerOptions APPEND | |
PROPERTY INTERFACE_COMPILE_OPTIONS "-fno-strict-aliasing") | |
endif() | |
endif() | |
endif() | |
if(NOT TARGET LEDA::LEDA) | |
add_library(LEDA::LEDA UNKNOWN IMPORTED) | |
set_target_properties(LEDA::LEDA PROPERTIES | |
INTERFACE_INCLUDE_DIRECTORIES "${LEDA_INCLUDE_DIR}" | |
INTERFACE_LINK_LIBRARIES LEDA::CompilerOptions) | |
foreach(config RELEASE DEBUG) | |
if(LEDA_LIBRARY_${config}) | |
set_property(TARGET LEDA::LEDA | |
PROPERTY IMPORTED_LOCATION_${config} "${LEDA_LIBRARY_${config}}") | |
set_property(TARGET LEDA::LEDA APPEND | |
PROPERTY IMPORTED_CONFIGURATIONS ${config}) | |
endif() | |
endforeach() | |
endif() | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment