forked from kassonlab/gmxapi
-
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.
Adds handling both for linking external muparser library and building from source if it is not found. Refs #3515 Change-Id: I09f725ea634d21e3a7d217cf99d28adb71d54473
- Loading branch information
Showing
30 changed files
with
10,338 additions
and
0 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
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
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,102 @@ | ||
# | ||
# This file is part of the GROMACS molecular simulation package. | ||
# | ||
# Copyright (c) 2020, by the GROMACS development team, led by | ||
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, | ||
# and including many others, as listed in the AUTHORS file in the | ||
# top-level source directory and at http://www.gromacs.org. | ||
# | ||
# GROMACS is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public License | ||
# as published by the Free Software Foundation; either version 2.1 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# GROMACS is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with GROMACS; if not, see | ||
# http://www.gnu.org/licenses, or write to the Free Software Foundation, | ||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# If you want to redistribute modifications to GROMACS, please | ||
# consider that scientific software is very special. Version | ||
# control is crucial - bugs must be traceable. We will be happy to | ||
# consider code for inclusion in the official distribution, but | ||
# derived work must not be called official GROMACS. Details are found | ||
# in the README & COPYING files - if they are missing, get the | ||
# official version at http://www.gromacs.org. | ||
# | ||
# To help us fund GROMACS development, we humbly ask that you cite | ||
# the research papers on the package. Check out http://www.gromacs.org. | ||
|
||
# This package tries to find an external muparser library, version | ||
# 2.3. | ||
# | ||
# MUPARSER_FOUND - muparser was found | ||
# MUPARSER_INCLUDE_DIR - muparser include directory | ||
# MUPARSER_LIBRARY - muparser library | ||
# MUPARSER_LINKS_OK - muparser libraries link correctly | ||
# MUPARSER_VERSION - muparser version string as "major.minor" | ||
# | ||
# CMake will search the CMAKE_PREFIX_PATH in the usual way, but if you | ||
# need more control then setting MUPARSER_INCLUDE_DIR and MUPARSER_LIBRARY | ||
# on the cmake command line to suitable values will work. | ||
|
||
include(CMakePushCheckState) | ||
cmake_push_check_state() | ||
|
||
find_package(PkgConfig QUIET) | ||
if(PKG_CONFIG_FOUND) | ||
if(MUPARSER_FIND_VERSION) | ||
if(MUPARSER_FIND_VERSION_EXACT) | ||
pkg_check_modules(PC_MUPARSER QUIET muparser=${MUPARSER_FIND_VERSION}) | ||
else() | ||
pkg_check_modules(PC_MUPARSER QUIET muparser>=${MUPARSER_FIND_VERSION}) | ||
endif() | ||
else() | ||
pkg_check_modules(PC_MUPARSER QUIET muparser) | ||
if (PC_MUPARSER_VERSION) | ||
string(REGEX REPLACE "^([0-9]+):([0-9]+)" "\\1.\\2" MUPARSER_VERSION "${PC_MUPARSER_VERSION}") | ||
endif() | ||
endif() | ||
endif() | ||
|
||
# Try to find muparser, perhaps with help from pkg-config | ||
find_path(MUPARSER_INCLUDE_DIR muParser.h HINTS "${PC_MUPARSER_INCLUDE_DIRS}" PATH_SUFFIXES include) | ||
find_library(MUPARSER_LIBRARY NAMES muparser HINTS "${PC_MUPARSER_LIBRARY_DIRS}" PATH_SUFFIXES lib64 lib) | ||
|
||
# Make sure we can also link, so that cross-compilation is properly supported | ||
if (MUPARSER_INCLUDE_DIR AND MUPARSER_LIBRARY) | ||
include(CheckCXXSourceCompiles) | ||
set(CMAKE_REQUIRED_INCLUDES ${MUPARSER_INCLUDE_DIR}) | ||
set(CMAKE_REQUIRED_LIBRARIES ${MUPARSER_LIBRARY}) | ||
check_cxx_source_compiles("#include <muParser.h>\nint main(){mu::Parser parser;}" MUPARSER_LINKS_OK) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(muparser | ||
FOUND_VAR | ||
MUPARSER_FOUND | ||
REQUIRED_VARS | ||
MUPARSER_INCLUDE_DIR | ||
MUPARSER_LIBRARY | ||
MUPARSER_LINKS_OK | ||
VERSION_VAR | ||
MUPARSER_VERSION) | ||
|
||
mark_as_advanced(MUPARSER_INCLUDE_DIR MUPARSER_LIBRARY) | ||
|
||
# Make a target that other targets can depend on just like this was a | ||
# library built in the main project. | ||
if (MUPARSER_FOUND) | ||
add_library(muparser INTERFACE IMPORTED) | ||
set_target_properties(muparser PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${MUPARSER_INCLUDE_DIR}" | ||
INTERFACE_LINK_LIBRARIES "${MUPARSER_LIBRARY}" | ||
) | ||
endif() | ||
|
||
cmake_pop_check_state() |
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,92 @@ | ||
# | ||
# This file is part of the GROMACS molecular simulation package. | ||
# | ||
# Copyright (c) 2020, by the GROMACS development team, led by | ||
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, | ||
# and including many others, as listed in the AUTHORS file in the | ||
# top-level source directory and at http://www.gromacs.org. | ||
# | ||
# GROMACS is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public License | ||
# as published by the Free Software Foundation; either version 2.1 | ||
# of the License, or (at your option) any later version. | ||
# | ||
# GROMACS is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with GROMACS; if not, see | ||
# http://www.gnu.org/licenses, or write to the Free Software Foundation, | ||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
# | ||
# If you want to redistribute modifications to GROMACS, please | ||
# consider that scientific software is very special. Version | ||
# control is crucial - bugs must be traceable. We will be happy to | ||
# consider code for inclusion in the official distribution, but | ||
# derived work must not be called official GROMACS. Details are found | ||
# in the README & COPYING files - if they are missing, get the | ||
# official version at http://www.gromacs.org. | ||
# | ||
# To help us fund GROMACS development, we humbly ask that you cite | ||
# the research papers on the package. Check out http://www.gromacs.org. | ||
|
||
set(GMX_MUPARSER_REQUIRED_VERSION "2.3") | ||
|
||
include(gmxOptionUtilities) | ||
|
||
# Make a three-state enumeration, defaulting to | ||
gmx_option_multichoice(GMX_USE_MUPARSER | ||
"How to handle the muparser dependency of GROMACS" | ||
INTERNAL | ||
INTERNAL EXTERNAL NONE) | ||
mark_as_advanced(GMX_USE_MUPARSER) | ||
|
||
# Make a fully functional muparser library target that libgromacs can | ||
# depend on regardless of how the user directed muparser support and/or | ||
# linking to work. | ||
function(gmx_manage_muparser) | ||
if(GMX_USE_MUPARSER STREQUAL "INTERNAL") | ||
# Create an object library for the muparser sources | ||
set(BUNDLED_MUPARSER_DIR "${CMAKE_SOURCE_DIR}/src/external/muparser") | ||
file(GLOB MUPARSER_SOURCES ${BUNDLED_MUPARSER_DIR}/*.cpp) | ||
add_library(muparser_objlib OBJECT ${MUPARSER_SOURCES}) | ||
# Ensure that the objects can be used in both STATIC and SHARED | ||
# libraries. | ||
set_target_properties(muparser_objlib PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Create an INTERFACE (ie. fake) library for muparser, that | ||
# libgromacs can depend on. The generator expression for the | ||
# target_sources expands to nothing when cmake builds the | ||
# export for libgromacs, so that it understands that we don't | ||
# install anything for this library - using plain source files | ||
# would not convey the right information. | ||
add_library(muparser INTERFACE) | ||
target_sources(muparser INTERFACE $<TARGET_OBJECTS:muparser_objlib>) | ||
target_include_directories(muparser SYSTEM INTERFACE $<BUILD_INTERFACE:${BUNDLED_MUPARSER_DIR}>) | ||
# Add the muparser interface library to the libgromacs Export name, even though | ||
# we will not be installing any content. | ||
install(TARGETS muparser EXPORT libgromacs) | ||
|
||
set(HAVE_MUPARSER 1 CACHE INTERNAL "Is muparser found?") | ||
elseif(GMX_USE_MUPARSER STREQUAL "EXTERNAL") | ||
# Find an external muparser library. | ||
find_package(muparser ${GMX_MUPARSER_REQUIRED_VERSION}) | ||
if(NOT MUPARSER_FOUND OR MUPARSER_VERSION VERSION_LESS GMX_MUPARSER_REQUIRED_VERSION) | ||
message(FATAL_ERROR "External muparser >= ${GMX_MUPARSER_REQUIRED_VERSION} could not be found, please adjust your pkg-config path to include the muparser.pc file") | ||
endif() | ||
|
||
set(HAVE_MUPARSER 1 CACHE INTERNAL "Is muparser found?") | ||
else() | ||
# Create a dummy link target so the calling code doesn't need to know | ||
# whether muparser support is being compiled. | ||
add_library(muparser INTERFACE) | ||
# Add the muparser interface library to the libgromacs Export name, even though | ||
# we will not be installing any content. | ||
install(TARGETS muparser EXPORT libgromacs) | ||
|
||
set(HAVE_MUPARSER 0 CACHE INTERNAL "Is muparser found?") | ||
endif() | ||
mark_as_advanced(HAVE_MUPARSER) | ||
endfunction() |
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
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
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,3 @@ | ||
muparser files | ||
============== | ||
Used from https://github.com/beltoforion/muparser/releases/tag/v2.3.2. |
Oops, something went wrong.