forked from BioMedIA/irtk-refactored-deprecated
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve custom find modules. Potentially solves BioMedIA#36
The following improvements were made: - Use same coding standards at Kitware/CMake. The goal is to manage to submit them upstream to limit maintenance. - Add support for custom install locations via ROOT envvars. - Add more helpful error output when an install of one of these dependencies is not found.
- Loading branch information
Ghislain Antony Vaillant
committed
Dec 22, 2015
1 parent
6e8799e
commit 89240d7
Showing
6 changed files
with
267 additions
and
109 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#.rst: | ||
# FindFLANN | ||
# --------- | ||
# | ||
# Find FLANN | ||
# | ||
# Find the FLANN C++ library. | ||
# | ||
# This module defines the following CMake variables: | ||
# | ||
# :: | ||
# | ||
# FLANN_FOUND - whether the library has been found | ||
# FLANN_INCLUDE_DIRS - location of the public headers | ||
# FLANN_LIBRARIES - path to the library | ||
# | ||
# This modules accept the following CMake / environment variables: | ||
# | ||
# :: | ||
# | ||
# FLANN_ROOT - install location of the library | ||
|
||
#============================================================================= | ||
# Copyright 2015 Ghislain Antony Vaillant <ghisvail@gmail.com> | ||
# | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# see accompanying file Copyright.txt for details. | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
# (To distribute this file outside of CMake, substitute the full | ||
# License text for the above reference.) | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_FLANN QUIET flann) | ||
|
||
find_path(FLANN_INCLUDE_DIR | ||
NAMES "flann.hpp" | ||
HINTS ENV FLANN_ROOT | ||
${FLANN_ROOT} | ||
${PC_FLANN_INCLUDEDIR} | ||
${PC_FLANN_INCLUDE_DIRS} | ||
PATH_SUFFIXES "include" | ||
"include/flann") | ||
|
||
if(FLANN_INCLUDE_DIR AND EXISTS "${FLANN_INCLUDE_DIR}/config.h") | ||
file(STRINGS "${FLANN_INCLUDE_DIR}/config.h" version_define_str | ||
REGEX "^#[\t ]*define[\t ]+FLANN_VERSION") | ||
if(${version_define_str} MATCHES "^#[\t ]*define[\t ]+FLANN_VERSION_[\t ]\"(.*)\"") | ||
set(FLANN_VERSION_STRING ${CMAKE_MATCH_1}) | ||
endif() | ||
endif() | ||
|
||
find_library(FLANN_LIBRARY | ||
NAMES "flann_cpp" | ||
HINTS ENV FLANN_ROOT | ||
${FLANN_ROOT} | ||
${PC_FLANN_LIBDIR} | ||
${PC_FLANN_LIBRARY_DIRS} | ||
PATH_SUFFIXES "lib" | ||
"lib/${CMAKE_LIBRARY_ARCHITECTURE}") | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(FLANN | ||
REQUIRED_VARS FLANN_LIBRARY | ||
FLANN_INCLUDE_DIR | ||
VERSION_VAR FLANN_VERSION_STRING) | ||
|
||
if(FLANN_FOUND) | ||
set(FLANN_INCLUDE_DIRS ${FLANN_INCLUDE_DIR}) | ||
set(FLANN_LIBRARIES ${FLANN_LIBRARY}) | ||
endif() | ||
|
||
mark_as_advanced(FLANN_INCLUDE_DIR | ||
FLANN_LIBRARY | ||
FLANN_VERSION_STRING) |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,79 @@ | ||
# Any copyright is dedicated to the Public Domain. | ||
# http://creativecommons.org/publicdomain/zero/1.0/ | ||
# Author: Ghislain Antony Vaillant | ||
#.rst: | ||
# FindLibLBFGS | ||
# ------------ | ||
# | ||
# Find LibLBFGS | ||
# | ||
# Find the libLBFGS C library. | ||
# | ||
# This module defines the following CMake variables: | ||
# | ||
# :: | ||
# | ||
# LibLBFGS_FOUND - whether the library has been found | ||
# LibLBFGS_INCLUDE_DIRS - location of the public headers | ||
# LibLBFGS_LIBRARIES - path to the library | ||
# | ||
# This modules accept the following CMake / environment variables: | ||
# | ||
# :: | ||
# | ||
# LIBLBFGS_ROOT - install location of the library | ||
|
||
# - Try to find LibLBFGS | ||
# Once done this will define | ||
# LIBLBFGS_FOUND - System has LibLBFGS | ||
# LIBLBFGS_INCLUDE_DIRS - The LibLBFGS include directories | ||
# LIBLBFGS_LIBRARIES - The libraries needed to use LibLBFGS | ||
# LIBLBFGS_DEFNINITIONS - Compiler switches required for using LibLBFGS | ||
#============================================================================= | ||
# Copyright 2015 Ghislain Antony Vaillant <ghisvail@gmail.com> | ||
# | ||
# The content of this file is inspired by the following example: | ||
# https://cmake.org/Wiki/CMake:How_To_Find_Libraries | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# see accompanying file Copyright.txt for details. | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
# (To distribute this file outside of CMake, substitute the full | ||
# License text for the above reference.) | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_LIBLBFGS QUIET liblbfgs) | ||
set(LIBLBFGS_DEFINITIONS ${PC_LIBLBFGS_CFLAGS_OTHER}) | ||
pkg_check_modules(PC_LibLBFGS QUIET liblbfgs) | ||
|
||
find_path(LIBLBFGS_INCLUDE_DIR lbfgs.h | ||
HINTS ${PC_LIBLBFGS_INCLUDEDIR} | ||
${PC_LIBLBFGS_INCLUDE_DIRS}) | ||
find_path(LibLBFGS_INCLUDE_DIR | ||
NAMES "lbfgs.h" | ||
HINTS ENV LIBLBFGS_ROOT | ||
${LIBLBFGS_ROOT} | ||
${PC_LibLBFGS_INCLUDEDIR} | ||
${PC_LibLBFGS_INCLUDE_DIRS} | ||
PATH_SUFFIXES "include") | ||
|
||
find_library(LIBLBFGS_LIBRARY NAMES lbfgs liblbfgs | ||
HINTS ${PC_LIBLBFGS_LIBDIR} | ||
${PC_LIBLBFGS_LIBRARY_DIRS}) | ||
if(LibLBFGS_INCLUDE_DIR AND EXISTS "${LibLBFGS_INCLUDE_DIR}/lbfgs.h") | ||
file(STRINGS "${LibLBFGS_INCLUDE_DIR}/lbfgs.h" version_comments | ||
REGEX "^-[\t ]Version[\t ]") | ||
list(GET version_comments 0 version_comment_latest) | ||
if(${version_comment_latest} MATCHES "^-[\t ]Version[\t ](.*)[\t ]") | ||
set(LibLBFGS_VERSION_STRING ${CMAKE_MATCH_1}) | ||
endif() | ||
endif() | ||
|
||
set(LIBLBFGS_LIBRARIES ${LIBLBFGS_LIBRARY}) | ||
set(LIBLBFGS_INCLUDE_DIRS ${LIBLBFGS_INCLUDE_DIR}) | ||
find_library(LibLBFGS_LIBRARY | ||
NAMES "lbfgs" | ||
HINTS ENV LIBLBFGS_ROOT | ||
${LIBLBFGS_ROOT} | ||
${PC_LibLBFGS_LIBDIR} | ||
${PC_LibLBFGS_LIBRARY_DIRS} | ||
PATH_SUFFIXES "lib" | ||
"lib/${CMAKE_LIBRARY_ARCHITECTURE}") | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(LibLBFGS DEFAULT_MSG | ||
LIBLBFGS_LIBRARY LIBLBFGS_INCLUDE_DIR) | ||
find_package_handle_standard_args(LibLBFGS | ||
FOUND_VAR LibLBFGS_FOUND | ||
REQUIRED_VARS LibLBFGS_LIBRARY | ||
LibLBFGS_INCLUDE_DIR | ||
VERSION_VAR LibLBFGS_VERSION_STRING) | ||
|
||
if(LibLBFGS_FOUND) | ||
set(LibLBFGS_INCLUDE_DIRS ${LibLBFGS_INCLUDE_DIR}) | ||
set(LibLBFGS_LIBRARIES ${LibLBFGS_LIBRARY}) | ||
endif() | ||
|
||
mark_as_advanced(LIBLBFGS_INCLUDE_DIR LIBLBFGS_LIBRARY) | ||
mark_as_advanced(LibLBFGS_INCLUDE_DIR | ||
LibLBFGS_LIBRARY | ||
LibLBFGS_VERSION_STRING) |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#.rst: | ||
# FindNiftiCLib | ||
# ------------- | ||
# | ||
# Find NiftiCLib | ||
# | ||
# Find the Nifti C libraries. | ||
# | ||
# This module defines the following CMake variables: | ||
# | ||
# :: | ||
# | ||
# NiftiCLib_FOUND - whether the libraries have been found | ||
# NiftiCLib_INCLUDE_DIRS - location of the public headers | ||
# NiftiCLib_LIBRARIES - path to the libraries | ||
# | ||
# This modules accept the following CMake / environment variables: | ||
# | ||
# :: | ||
# | ||
# NIFTICLIB_ROOT - install location of the libraries | ||
|
||
#============================================================================= | ||
# Copyright 2015 Ghislain Antony Vaillant <ghisvail@gmail.com> | ||
# | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# see accompanying file Copyright.txt for details. | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
# (To distribute this file outside of CMake, substitute the full | ||
# License text for the above reference.) | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(PC_NiftiCLib QUIET flann) | ||
|
||
find_path(NiftiCLib_INCLUDE_DIR | ||
NAMES "nifti1.h" | ||
HINTS ENV NIFTICLIB_ROOT | ||
${NIFTICLIB_ROOT} | ||
${PC_NiftiCLib_INCLUDEDIR} | ||
${PC_NiftiCLib_INCLUDE_DIRS} | ||
PATH_SUFFIXES "include" | ||
"include/nifti") | ||
|
||
find_library(NiftiCLib_CDF_LIBRARY | ||
NAMES "nifticdf" | ||
HINTS ENV NIFTICLIB_ROOT | ||
${NIFTICLIB_ROOT} | ||
${PC_NiftiCLib_LIBDIR} | ||
${PC_NiftiCLib_LIBRARY_DIRS} | ||
PATH_SUFFIXES "lib" | ||
"lib/${CMAKE_LIBRARY_ARCHITECTURE}") | ||
|
||
find_library(NiftiCLib_IO_LIBRARY | ||
NAMES "niftiio" | ||
HINTS ENV NIFTICLIB_ROOT | ||
${NIFTICLIB_ROOT} | ||
${PC_NiftiCLib_LIBDIR} | ||
${PC_NiftiCLib_LIBRARY_DIRS} | ||
PATH_SUFFIXES "lib" | ||
"lib/${CMAKE_LIBRARY_ARCHITECTURE}") | ||
|
||
find_library(NiftiCLib_ZNZ_LIBRARY | ||
NAMES "znz" | ||
HINTS ENV NIFTICLIB_ROOT | ||
${NIFTICLIB_ROOT} | ||
${PC_NiftiCLib_LIBDIR} | ||
${PC_NiftiCLib_LIBRARY_DIRS} | ||
PATH_SUFFIXES "lib" | ||
"lib/${CMAKE_LIBRARY_ARCHITECTURE}") | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(NiftiCLib | ||
FOUND_VAR NiftiCLib_FOUND | ||
REQUIRED_VARS NiftiCLib_IO_LIBRARY | ||
NiftiCLib_CDF_LIBRARY | ||
NiftiCLib_ZNZ_LIBRARY | ||
NiftiCLib_INCLUDE_DIR) | ||
|
||
if(NiftiCLib_FOUND) | ||
set(NiftiCLib_INCLUDE_DIRS ${NiftiCLib_INCLUDE_DIR}) | ||
set(NiftiCLib_LIBRARIES ${NiftiCLib_CDF_LIBRARY} | ||
${NiftiCLib_IO_LIBRARY} | ||
${NiftiCLib_ZNZ_LIBRARY}) | ||
endif() | ||
|
||
mark_as_advanced(NiftiCLib_INCLUDE_DIR | ||
NiftiCLib_CDF_LIBRARY | ||
NiftiCLib_IO_LIBRARY | ||
NiftiCLib_ZNZ_LIBRARY) |
Oops, something went wrong.