Using external cmake modules
This commit is contained in:
parent
e16ed8a5e5
commit
99e5fa4e25
@ -1,102 +0,0 @@
|
||||
# - Add options without repeating them on the command line
|
||||
#
|
||||
# Synopsis:
|
||||
#
|
||||
# add_options (lang build opts)
|
||||
#
|
||||
# where:
|
||||
#
|
||||
# lang Name of the language whose compiler should receive the
|
||||
# options, e.g. CXX. If a comma-separated list is received
|
||||
# then the option is added for all those languages. Use the
|
||||
# special value ALL_LANGUAGES for these languages: CXX, C
|
||||
# and Fortran
|
||||
#
|
||||
# build Kind of build to which this options should apply,
|
||||
# such as DEBUG and RELEASE. This can also be a comma-
|
||||
# separated list. Use the special value ALL_BUILDS to apply
|
||||
# to all builds.
|
||||
#
|
||||
# opts List of options to add. Each should be quoted.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# add_options (CXX RELEASE "-O3" "-DNDEBUG" "-Wall")
|
||||
|
||||
function (add_options langs builds)
|
||||
# special handling of empty language specification
|
||||
if ("${langs}" STREQUAL "ALL_LANGUAGES")
|
||||
set (langs CXX C Fortran)
|
||||
endif ("${langs}" STREQUAL "ALL_LANGUAGES")
|
||||
foreach (lang IN LISTS langs)
|
||||
# prepend underscore if necessary
|
||||
foreach (build IN LISTS builds)
|
||||
if (NOT ("${build}" STREQUAL "ALL_BUILDS"))
|
||||
set (_bld "_${build}")
|
||||
string (TOUPPER "${_bld}" _bld)
|
||||
else (NOT ("${build}" STREQUAL "ALL_BUILDS"))
|
||||
set (_bld "")
|
||||
endif (NOT ("${build}" STREQUAL "ALL_BUILDS"))
|
||||
# if we want everything in the "global" flag, then simply
|
||||
# ignore the build type here and go add everything to that one
|
||||
if (CMAKE_NOT_USING_CONFIG_FLAGS)
|
||||
set (_bld "")
|
||||
endif ()
|
||||
foreach (_opt IN LISTS ARGN)
|
||||
set (_var "CMAKE_${lang}_FLAGS${_bld}")
|
||||
#message (STATUS "Adding \"${_opt}\" to \${${_var}}")
|
||||
# remove it first
|
||||
string (REPLACE "${_opt}" "" _without "${${_var}}")
|
||||
string (STRIP "${_without}" _without)
|
||||
# we need to strip this one as well, so they are comparable
|
||||
string (STRIP "${${_var}}" _stripped)
|
||||
# if it wasn't there, then add it at the end
|
||||
if ("${_without}" STREQUAL "${_stripped}")
|
||||
# don't add any extra spaces if no options yet are set
|
||||
if (NOT ${_stripped} STREQUAL "")
|
||||
set (${_var} "${_stripped} ${_opt}")
|
||||
else (NOT ${_stripped} STREQUAL "")
|
||||
set (${_var} "${_opt}")
|
||||
endif (NOT ${_stripped} STREQUAL "")
|
||||
set (${_var} "${${_var}}" PARENT_SCOPE)
|
||||
endif ("${_without}" STREQUAL "${_stripped}")
|
||||
endforeach (_opt)
|
||||
endforeach (build)
|
||||
endforeach (lang)
|
||||
endfunction (add_options lang build)
|
||||
|
||||
# set varname to flag unless user has specified something that matches regex
|
||||
function (set_default_option lang varname flag regex)
|
||||
# lang is either C, CXX or Fortran
|
||||
if ("${lang}" STREQUAL "Fortran")
|
||||
set (letter "F")
|
||||
else ()
|
||||
set (letter "${lang}")
|
||||
endif ()
|
||||
string (TOUPPER "${CMAKE_BUILD_TYPE}" _build)
|
||||
if ((NOT ("$ENV{${letter}FLAGS}" MATCHES "${regex}"))
|
||||
AND (NOT ("${CMAKE_${lang}_FLAGS}" MATCHES "${regex}"))
|
||||
AND (NOT ("${CMAKE_${lang}_FLAGS_${_build}}" MATCHES "${regex}")))
|
||||
set (${varname} ${flag} PARENT_SCOPE)
|
||||
else ()
|
||||
set (${varname} PARENT_SCOPE)
|
||||
endif ()
|
||||
endfunction (set_default_option)
|
||||
|
||||
# clear default options as a proxy for not using any default options
|
||||
# at all. there is one *huge* problem with this: CMake runs the platform
|
||||
# initialization before executing any line at all in the project and
|
||||
# there seems to be no way to disable that behaviour, so we cannot really
|
||||
# distinguish between a platform default and something that the user has
|
||||
# passed on the command line. the best thing we can do is to all user-
|
||||
# defined setting if they are something other than the platform default.
|
||||
macro (no_default_options)
|
||||
foreach (lang IN ITEMS C CXX Fortran)
|
||||
foreach (build IN ITEMS DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
|
||||
if ("${CMAKE_${lang}_FLAGS_${build}}" STREQUAL "${CMAKE_${lang}_FLAGS_${build}_INIT}")
|
||||
# for some strange reason we cannot clear this flag, only set it to empty
|
||||
set (CMAKE_${lang}_FLAGS_${build} "")
|
||||
endif ()
|
||||
endforeach (build)
|
||||
endforeach (lang)
|
||||
endmacro (no_default_options)
|
@ -1,111 +0,0 @@
|
||||
# - Create config.h based on a list of variables
|
||||
#
|
||||
# Synopsis:
|
||||
# configure_vars (FILE syntax filename verb varlist)
|
||||
# where
|
||||
# syntax CXX or CMAKE, depending on target
|
||||
# filename Full path (including name) of config.h
|
||||
# verb WRITE or APPEND if truncating or not
|
||||
# varlist List of variable names that has been defined
|
||||
#
|
||||
# In addition, this function will define HAVE_CONFIG_H for the
|
||||
# following compilations, (only) if the filename is "config.h".
|
||||
#
|
||||
# Example:
|
||||
# list (APPEND FOO_CONFIG_VARS
|
||||
# "/* bar library */"
|
||||
# "HAVE_BAR"
|
||||
# "HAVE_BAR_VERSION_2"
|
||||
# )
|
||||
# configure_vars (
|
||||
# FILE CXX ${PROJECT_BINARY_DIR}/config.h
|
||||
# WRITE ${FOO_CONFIG_VARS}
|
||||
# )
|
||||
|
||||
# Copyright (C) 2012 Uni Research AS
|
||||
# This file is licensed under the GNU General Public License v3.0
|
||||
|
||||
function (configure_vars obj syntax filename verb)
|
||||
# this is just to make the syntax look like the build-in commands
|
||||
if (NOT ("${obj}" STREQUAL "FILE" AND
|
||||
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
|
||||
message (FATAL_ERROR "Syntax error in argument list")
|
||||
endif (NOT ("${obj}" STREQUAL "FILE" AND
|
||||
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
|
||||
if (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
|
||||
message (FATAL_ERROR "Invalid target syntax \"${syntax}\"")
|
||||
endif (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
|
||||
|
||||
# truncate the file if the verb was "WRITE"
|
||||
if (verb STREQUAL "WRITE")
|
||||
file (WRITE "${filename}" "")
|
||||
endif (verb STREQUAL "WRITE")
|
||||
|
||||
# whenever we use this, we also signal to the header files that we
|
||||
# have "config.h". add this before any other files (known till now)
|
||||
# to avoid confusion from other configuration files.
|
||||
get_filename_component (_config_path "${filename}" PATH)
|
||||
get_filename_component (_config_file "${filename}" NAME)
|
||||
if ("${_config_file}" MATCHES "config\\.h(\\..+)?")
|
||||
add_definitions (-DHAVE_CONFIG_H=1)
|
||||
include_directories (BEFORE "${_config_path}")
|
||||
endif ("${_config_file}" MATCHES "config\\.h(\\..+)?")
|
||||
|
||||
# only write the current value of each variable once
|
||||
set (_args ${ARGN})
|
||||
if (_args)
|
||||
list (REMOVE_DUPLICATES _args)
|
||||
endif (_args)
|
||||
|
||||
# process each variable
|
||||
set (_prev_verbatim TRUE)
|
||||
foreach (_var IN LISTS _args)
|
||||
|
||||
# massage the name to remove source code formatting
|
||||
string (REGEX REPLACE "^[\\n\\t\\ ]+" "" _var "${_var}")
|
||||
string (REGEX REPLACE "[\\n\\t\\ ]+$" "" _var "${_var}")
|
||||
|
||||
# if the name of a variable has the syntax of a comments, write it
|
||||
# verbatim to the file; this can be used to create headings
|
||||
if ("${_var}" MATCHES "^/[/*]")
|
||||
if (NOT _prev_verbatim)
|
||||
file (APPEND "${filename}" "\n")
|
||||
endif (NOT _prev_verbatim)
|
||||
file (APPEND "${filename}" "${_var}\n")
|
||||
set (_prev_verbatim TRUE)
|
||||
|
||||
else ("${_var}" MATCHES "^/[/*]")
|
||||
|
||||
# write a CMake statements that warns if the value has changed
|
||||
if ("${syntax}" STREQUAL "CMAKE")
|
||||
set (_db "\${") # to avoid parsing problems
|
||||
file (APPEND "${filename}" "if (DEFINED ${_var} AND NOT \"${_db}${_var}}\" STREQUAL \"${${_var}}\")\n")
|
||||
file (APPEND "${filename}" "\tmessage (WARNING \"Incompatible value \\\"${_db}${_var}}\\\" of variable \\\"${_var}\\\"\")\n")
|
||||
file (APPEND "${filename}" "endif ()\n")
|
||||
endif ()
|
||||
|
||||
# check for empty variable; variables that are explicitly set to false
|
||||
# is not included in this clause
|
||||
if ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
|
||||
if ("${syntax}" STREQUAL "CMAKE")
|
||||
file (APPEND "${filename}" "set (${_var})\n")
|
||||
else ("${syntax}" STREQUAL "CMAKE")
|
||||
file (APPEND "${filename}" "/* #undef ${_var} */\n")
|
||||
endif ("${syntax}" STREQUAL "CMAKE")
|
||||
else ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
|
||||
# write to file using the correct syntax
|
||||
if ("${syntax}" STREQUAL "CMAKE")
|
||||
# escape backslash and double quote characters
|
||||
string (REPLACE "\\" "\\\\" _quoted "${${_var}}")
|
||||
string (REPLACE "\"" "\\\"" _quoted "${_quoted}")
|
||||
|
||||
file (APPEND "${filename}" "set (${_var} \"${_quoted}\")\n")
|
||||
else ("${syntax}" STREQUAL "CMAKE")
|
||||
file (APPEND "${filename}" "#define ${_var} ${${_var}}\n")
|
||||
endif ("${syntax}" STREQUAL "CMAKE")
|
||||
|
||||
endif ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
|
||||
set (_prev_verbatim FALSE)
|
||||
endif ("${_var}" MATCHES "^/[/*]")
|
||||
endforeach(_var)
|
||||
endfunction (configure_vars obj syntax filename verb)
|
@ -1,38 +0,0 @@
|
||||
# - Remove duplicate library declarations
|
||||
#
|
||||
# Synopsis:
|
||||
#
|
||||
# remove_duplicate_libraries (module)
|
||||
#
|
||||
# where
|
||||
# module Name of the module whose libraries should be pruned
|
||||
|
||||
# Copyright (C) 2013 Uni Research AS
|
||||
# This file is licensed under the GNU General Public License v3.0
|
||||
|
||||
# libraries should always be trimmed from the beginning, so that also
|
||||
# missing functions in those later in the list will be resolved
|
||||
macro (remove_duplicate_libraries module)
|
||||
if (DEFINED ${module}_LIBRARIES)
|
||||
list (REVERSE ${module}_LIBRARIES)
|
||||
list (REMOVE_DUPLICATES ${module}_LIBRARIES)
|
||||
list (REVERSE ${module}_LIBRARIES)
|
||||
endif (DEFINED ${module}_LIBRARIES)
|
||||
endmacro (remove_duplicate_libraries module)
|
||||
|
||||
# headers can be trimmed from the end, since adding a directory to
|
||||
# the list is an idempotent action
|
||||
macro (remove_duplicate_var module suffix)
|
||||
if (DEFINED ${module}_${suffix})
|
||||
list (REMOVE_DUPLICATES ${module}_${suffix})
|
||||
endif (DEFINED ${module}_${suffix})
|
||||
endmacro (remove_duplicate_var module suffix)
|
||||
|
||||
# fix up both headers and libraries, in case two dependencies have
|
||||
# included the same second-level library independently
|
||||
macro (remove_dup_deps module)
|
||||
remove_duplicate_var (${module} INCLUDE_DIRS)
|
||||
remove_duplicate_var (${module} LINKER_FLAGS)
|
||||
remove_duplicate_var (${module} CONFIG_VARS)
|
||||
remove_duplicate_libraries (${module})
|
||||
endmacro (remove_dup_deps module)
|
@ -1,453 +0,0 @@
|
||||
#
|
||||
# Module that checks for supported C++11 (former C++0x) features.
|
||||
#
|
||||
# Sets the follwing variable:
|
||||
#
|
||||
# HAVE_TYPE_TRAITS True if the <type_traits> header is available and implements sufficient functionality
|
||||
# HAVE_SHARED_PTR True if std::shared_ptr is available
|
||||
# HAVE_UNIQUE_PTR True if std::unique_ptr is available
|
||||
# HAVE_NULLPTR True if nullptr is available
|
||||
# HAVE_REGEX True if std::regex available and sufficiently usable
|
||||
# HAVE_ARRAY True if header <array> and fill() are available
|
||||
# HAVE_ATTRIBUTE_ALWAYS_INLINE True if attribute always inline is supported
|
||||
# HAS_ATTRIBUTE_UNUSED True if attribute unused is supported
|
||||
# HAS_ATTRIBUTE_DEPRECATED True if attribute deprecated is supported
|
||||
# HAS_ATTRIBUTE_DEPRECATED_MSG True if attribute deprecated("msg") is supported
|
||||
# HAVE_CONSTEXPR True if constexpr attribute is available
|
||||
# HAVE_INTEGRAL_CONSTANT True if compiler supports integral_constant
|
||||
# HAVE_STATIC_ASSERT True if static_assert is available
|
||||
# HAVE_AUTO True if the compiler supports the auto keyword
|
||||
# HAVE_VARIADIC_TEMPLATES True if variadic templates are supported
|
||||
# HAVE_VARIADIC_CONSTRUCTOR_SFINAE True if variadic constructor sfinae is supported
|
||||
# HAVE_RVALUE_REFERENCES True if rvalue references are supported
|
||||
# HAVE_TUPLE True if std::tuple is available
|
||||
# HAVE_TR1_TUPLE True if std::tr1::tuple is available
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
include(CheckCXXSourceRuns)
|
||||
|
||||
# test for C++11 flags
|
||||
include(TestCXXAcceptsFlag)
|
||||
include(CheckIncludeFileCXX)
|
||||
|
||||
# macro to only add option once
|
||||
include(AddOptions)
|
||||
|
||||
# try to use compiler flag -std=c++11
|
||||
CHECK_CXX_ACCEPTS_FLAG("-std=c++11" CXX_FLAG_CXX11)
|
||||
if(CXX_FLAG_CXX11)
|
||||
add_options (CXX ALL_BUILDS "-std=c++11")
|
||||
set(CXX_STD0X_FLAGS "-std=c++11")
|
||||
else()
|
||||
# try to use compiler flag -std=c++0x for older compilers
|
||||
CHECK_CXX_ACCEPTS_FLAG("-std=c++0x" CXX_FLAG_CXX0X)
|
||||
if(CXX_FLAG_CXX0X)
|
||||
add_options (CXX ALL_BUILDS "-std=c++0x")
|
||||
set(CXX_STD0X_FLAGS "-std=c++0x")
|
||||
endif(CXX_FLAG_CXX0X)
|
||||
endif(CXX_FLAG_CXX11)
|
||||
|
||||
# if we are building with an Apple toolchain in MacOS X,
|
||||
# we cannot use the old GCC 4.2 fork, but must use the
|
||||
# new runtime library
|
||||
set (CXX_STDLIB_FLAGS)
|
||||
string (TOUPPER "${CMAKE_CXX_COMPILER_ID}" _comp_id)
|
||||
if (APPLE AND (_comp_id MATCHES "CLANG"))
|
||||
CHECK_CXX_ACCEPTS_FLAG ("-stdlib=libc++" CXX_FLAG_STDLIB_LIBCXX)
|
||||
if (CXX_FLAG_STDLIB_LIBCXX)
|
||||
add_options (CXX ALL_BUILDS "-stdlib=libc++")
|
||||
set (CXX_STDLIB_FLAGS "-stdlib=libc++")
|
||||
endif (CXX_FLAG_STDLIB_LIBCXX)
|
||||
endif (APPLE AND (_comp_id MATCHES "CLANG"))
|
||||
|
||||
# to format the command-line options pretty, we have an optional space
|
||||
if (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
|
||||
set (CXX_SPACE " ")
|
||||
else (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
|
||||
set (CXX_SPACE)
|
||||
endif (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
|
||||
|
||||
# perform tests
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
# std::is_convertible, std::is_base_of
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <type_traits>
|
||||
|
||||
class Base {};
|
||||
class Derived : public Base {};
|
||||
|
||||
int main()
|
||||
{
|
||||
bool foo = std::is_convertible<int, double>::value;
|
||||
bool bar = std::is_base_of<Base, Derived>::value;
|
||||
bool foobar = std::is_integral<double>::value;
|
||||
return 0;
|
||||
}
|
||||
" HAVE_TYPE_TRAITS
|
||||
)
|
||||
|
||||
# nullptr
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <memory>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
std::shared_ptr<int> foo(new int(123));
|
||||
return 0;
|
||||
}
|
||||
" HAVE_SHARED_PTR
|
||||
)
|
||||
|
||||
# this is required by dune-common to avoid linker errors. "fun"!
|
||||
if (HAVE_SHARED_PTR)
|
||||
set(HAVE_MAKE_SHARED 1)
|
||||
set(SHARED_PTR_HEADER "<memory>")
|
||||
set(SHARED_PTR_NAMESPACE "std")
|
||||
endif()
|
||||
|
||||
# nullptr
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <memory>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
std::unique_ptr<int> foo(new int(123));
|
||||
return 0;
|
||||
}
|
||||
" HAVE_UNIQUE_PTR
|
||||
)
|
||||
|
||||
# nullptr
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
int main(void)
|
||||
{
|
||||
char* ch = nullptr;
|
||||
return 0;
|
||||
}
|
||||
" HAVE_NULLPTR
|
||||
)
|
||||
|
||||
# <regex>
|
||||
CHECK_CXX_SOURCE_RUNS("
|
||||
#include <regex>
|
||||
int main(void)
|
||||
{
|
||||
std::regex r(\"AB.*|BC+|DE.+\", std::regex::extended);
|
||||
if (!std::regex_match(\"AB\", r))
|
||||
return 1;
|
||||
if (!std::regex_match(\"ABC\", r))
|
||||
return 2;
|
||||
if (!std::regex_match(\"ABC!#\", r))
|
||||
return 3;
|
||||
if (std::regex_match(\"B\", r))
|
||||
return 4;
|
||||
if (!std::regex_match(\"BC\", r))
|
||||
return 5;
|
||||
if (std::regex_match(\"BCE\", r))
|
||||
return 6;
|
||||
if (std::regex_match(\"DE\", r))
|
||||
return 7;
|
||||
if (!std::regex_match(\"DEF\", r))
|
||||
return 8;
|
||||
return 0;
|
||||
}
|
||||
" HAVE_REGEX
|
||||
)
|
||||
|
||||
# constexpr
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
template <class T>
|
||||
inline constexpr int foo(T bar) { return bar*2; }
|
||||
int main(void)
|
||||
{
|
||||
constexpr int foobar = foo(100);
|
||||
return 0;
|
||||
}
|
||||
" HAVE_CONSTEXPR
|
||||
)
|
||||
|
||||
# array and fill
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <array>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
std::array<int,2> a;
|
||||
a.fill(9);
|
||||
return 0;
|
||||
}
|
||||
" HAVE_ARRAY
|
||||
)
|
||||
|
||||
# Check whether if std::integral_constant< T, v > is supported and casts into T
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <type_traits>
|
||||
void f( int ){}
|
||||
|
||||
int main(void){
|
||||
f( std::integral_constant< int, 42 >() );
|
||||
}
|
||||
" HAVE_INTEGRAL_CONSTANT
|
||||
)
|
||||
|
||||
# Check whether if <tuple> is available
|
||||
check_include_file_cxx("tuple" HAVE_TUPLE)
|
||||
|
||||
# Check whether if <tr1/tuple> is available
|
||||
check_include_file_cxx("tr1/tuple" HAVE_TR1_TUPLE)
|
||||
|
||||
# __attribute__((always_inline))
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
void __attribute__((always_inline)) foo(void) {}
|
||||
int main(void)
|
||||
{
|
||||
foo();
|
||||
return 0;
|
||||
};
|
||||
" HAVE_ATTRIBUTE_ALWAYS_INLINE
|
||||
)
|
||||
|
||||
# __attribute__((unused))
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
int main(void)
|
||||
{
|
||||
int __attribute__((unused)) foo;
|
||||
return 0;
|
||||
};
|
||||
" HAS_ATTRIBUTE_UNUSED
|
||||
)
|
||||
|
||||
# __attribute__((deprecated))
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#define DEP __attribute__((deprecated))
|
||||
class bar
|
||||
{
|
||||
bar() DEP;
|
||||
};
|
||||
|
||||
class peng { } DEP;
|
||||
|
||||
template <class T>
|
||||
class t_bar
|
||||
{
|
||||
t_bar() DEP;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class t_peng {
|
||||
t_peng() {};
|
||||
} DEP;
|
||||
|
||||
void foo() DEP;
|
||||
|
||||
void foo() {};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
" HAS_ATTRIBUTE_DEPRECATED
|
||||
)
|
||||
|
||||
# __attribute__((deprecated("msg")))
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#define DEP __attribute__((deprecated(\"message\")))
|
||||
class bar {
|
||||
bar() DEP;
|
||||
};
|
||||
|
||||
class peng { } DEP;
|
||||
|
||||
template <class T>
|
||||
class t_bar
|
||||
{
|
||||
t_bar() DEP;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class t_peng
|
||||
{
|
||||
t_peng() {};
|
||||
} DEP;
|
||||
|
||||
void foo() DEP;
|
||||
|
||||
void foo() {};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
" HAS_ATTRIBUTE_DEPRECATED_MSG
|
||||
)
|
||||
|
||||
# static assert
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
int main(void)
|
||||
{
|
||||
static_assert(true,\"MSG\");
|
||||
return 0;
|
||||
}
|
||||
" HAVE_STATIC_ASSERT
|
||||
)
|
||||
|
||||
# auto keyword
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
int main(void)
|
||||
{
|
||||
auto foo = 1.23;
|
||||
return 0;
|
||||
}
|
||||
" HAVE_AUTO
|
||||
)
|
||||
|
||||
# variadic template support
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <cassert>
|
||||
|
||||
template<typename... T>
|
||||
int addints(T... x);
|
||||
|
||||
int add_ints()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<typename T1, typename... T>
|
||||
int add_ints(T1 t1, T... t)
|
||||
{
|
||||
return t1 + add_ints(t...);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
assert( 5 == add_ints(9,3,-5,-2) );
|
||||
return 0;
|
||||
}
|
||||
" HAVE_VARIADIC_TEMPLATES
|
||||
)
|
||||
|
||||
# SFINAE on variadic template constructors within template classes
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <functional>
|
||||
|
||||
template<typename... U>
|
||||
struct A
|
||||
{
|
||||
template<typename... T,
|
||||
typename = typename std::enable_if<(sizeof...(T) < 2)>::type
|
||||
>
|
||||
A(T... t)
|
||||
: i(1)
|
||||
{}
|
||||
|
||||
template<typename... T,
|
||||
typename = typename std::enable_if<(sizeof...(T) >= 2)>::type,
|
||||
typename = void
|
||||
>
|
||||
A(T... t)
|
||||
: i(-1)
|
||||
{}
|
||||
|
||||
A()
|
||||
: i(1)
|
||||
{}
|
||||
|
||||
int i;
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return (A<int>().i + A<int>(2).i + A<int>(\"foo\",3.4).i + A<int>(8,'a',A<int>()).i == 0 ? 0 : 1);
|
||||
}
|
||||
" HAVE_VARIADIC_CONSTRUCTOR_SFINAE
|
||||
)
|
||||
|
||||
# rvalue references
|
||||
CHECK_CXX_SOURCE_COMPILES("
|
||||
#include <cassert>
|
||||
#include <utility>
|
||||
int foo(int&& x) { return 1; }
|
||||
int foo(const int& x) { return -1; }
|
||||
|
||||
template<typename T>
|
||||
int forward(T&& x)
|
||||
{
|
||||
return foo(std::forward<T>(x));
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i = 0;
|
||||
assert( forward(i) + forward(int(2)) == 0);
|
||||
return 0;
|
||||
}
|
||||
" HAVE_RVALUE_REFERENCES
|
||||
)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckIncludeFileCXX)
|
||||
# Search for some tr1 headers
|
||||
foreach(_HEADER tuple tr1/tuple type_traits tr1/type_traits)
|
||||
string(REPLACE "/" "_" _HEADER_VAR ${_HEADER})
|
||||
string(TOUPPER ${_HEADER_VAR} _HEADER_VAR )
|
||||
check_include_file_cxx(${_HEADER} "HAVE_${_HEADER_VAR}")
|
||||
endforeach(_HEADER tuple tr1/tuple tr1/type_traits)
|
||||
|
||||
# make sure that the C++-11 features implemented by the compiler are a
|
||||
# superset of those provided by GCC 4.4. This makes the test fail on
|
||||
# all GCC compilers before 4.4.
|
||||
set(CXX_FEATURES_MISSING "")
|
||||
if (NOT HAVE_TYPE_TRAITS)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - Sufficiently conformant type traits (defined by the 'type_traits' header file)\n")
|
||||
endif()
|
||||
if (NOT HAVE_SHARED_PTR)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - Shared pointers (the std::shared_ptr class)\n")
|
||||
endif()
|
||||
if (NOT HAVE_UNIQUE_PTR)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - Unique pointers (the std::unique_ptr class)\n")
|
||||
endif()
|
||||
if (NOT HAVE_ARRAY)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - Statically sized arrays (the std::array class)\n")
|
||||
endif()
|
||||
if (NOT HAVE_STATIC_ASSERT)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - Static assertations (the static_assert() mechanism)\n")
|
||||
endif()
|
||||
if (NOT HAVE_AUTO)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - Automatically typed variables (the 'auto' keyword)\n")
|
||||
endif()
|
||||
if (NOT HAVE_VARIADIC_TEMPLATES)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - Variable number of template arguments\n")
|
||||
endif()
|
||||
if (NOT HAVE_VARIADIC_CONSTRUCTOR_SFINAE)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - Constructors with variable number of template arguments obeying the SFINAE (specialization failure is not an error) rule\n")
|
||||
endif()
|
||||
if (NOT HAVE_RVALUE_REFERENCES)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - References to rvalue objects\n")
|
||||
endif()
|
||||
if (NOT HAVE_TUPLE)
|
||||
set(CXX_FEATURES_MISSING
|
||||
"${CXX_FEATURES_MISSING} - Tuples (the std::tuple class)\n")
|
||||
endif()
|
||||
|
||||
if(CXX_FEATURES_MISSING)
|
||||
set (CXX11FEATURES_FOUND FALSE)
|
||||
if (CXX11Features_FIND_REQUIRED)
|
||||
message(FATAL_ERROR
|
||||
"Your C++ compiler does not support the minimum set of C++-2011 features required. "
|
||||
"Make sure to use a compiler which implements all C++-2011 features provided by GCC 4.4. "
|
||||
"Your compiler does not seem to implement the following features:\n"
|
||||
"${CXX_FEATURES_MISSING}")
|
||||
endif()
|
||||
else ()
|
||||
set (CXX11FEATURES_FOUND TRUE)
|
||||
endif()
|
@ -1,240 +0,0 @@
|
||||
# - Find the Ensemble-based Reservoir Tool (ERT)
|
||||
#
|
||||
# Set the cache variable ERT_ROOT to the install location of the ERT
|
||||
# libraries and header files.
|
||||
#
|
||||
# If found, it sets these variables:
|
||||
#
|
||||
# ERT_INCLUDE_DIRS Header file directories
|
||||
# ERT_LIBRARIES Archives and shared objects
|
||||
# ERT_CONFIG_VARS Definitions that goes in config.h
|
||||
# ERT_LINKER_FLAGS Options that must be passed to linker
|
||||
#
|
||||
# It will also add to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS if necessary to
|
||||
# link with the ERT libraries.
|
||||
|
||||
# variables to pass on to other packages
|
||||
if (FIND_QUIETLY)
|
||||
set (ERT_QUIET "QUIET")
|
||||
else (FIND_QUIETLY)
|
||||
set (ERT_QUIET "")
|
||||
endif (FIND_QUIETLY)
|
||||
|
||||
# if a directory has been specified by the user, then don't go look
|
||||
# in the system directories as well
|
||||
if (ERT_ROOT)
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
else (ERT_ROOT)
|
||||
set (_no_default_path "")
|
||||
endif (ERT_ROOT)
|
||||
|
||||
# ERT doesn't have any config-mode file, so we need to specify the root
|
||||
# directory in its own variable
|
||||
find_path (ERT_ECL_INCLUDE_DIR
|
||||
NAMES "ert/ecl/ecl_util.h"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "../ert"
|
||||
PATH_SUFFIXES "devel/libecl/include/" "include"
|
||||
DOC "Path to ERT Eclipse library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_path (ERT_UTIL_INCLUDE_DIR
|
||||
NAMES "ert/util/stringlist.h"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "../ert"
|
||||
PATH_SUFFIXES "devel/libert_util/include/" "include"
|
||||
DOC "Path to ERT Eclipse library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_path (ERT_GEN_INCLUDE_DIR
|
||||
NAMES "ert/util/int_vector.h"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "libert_util/include/" "include"
|
||||
DOC "Path to ERT generated library header files"
|
||||
${_no_default_path}
|
||||
)
|
||||
|
||||
# need all of these libraries
|
||||
if (CMAKE_SIZEOF_VOID_P)
|
||||
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||
endif (CMAKE_SIZEOF_VOID_P)
|
||||
find_library (ERT_LIBRARY_ECL
|
||||
NAMES "ecl"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Eclipse library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_library (ERT_LIBRARY_ECL_WELL
|
||||
NAMES "ecl_well"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Eclipse library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_library (ERT_LIBRARY_GEOMETRY
|
||||
NAMES "ert_geometry"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Geometry library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
find_library (ERT_LIBRARY_UTIL
|
||||
NAMES "ert_util"
|
||||
HINTS "${ERT_ROOT}"
|
||||
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
|
||||
"${PROJECT_BINARY_DIR}/../ert/devel"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
DOC "Path to ERT Utilities library archive/shared object files"
|
||||
${_no_default_path}
|
||||
)
|
||||
# the "library" found here is actually a list of several files
|
||||
list (APPEND ERT_INCLUDE_DIR
|
||||
${ERT_ECL_INCLUDE_DIR}
|
||||
${ERT_UTIL_INCLUDE_DIR}
|
||||
${ERT_GEN_INCLUDE_DIR}
|
||||
)
|
||||
list (APPEND ERT_LIBRARY
|
||||
${ERT_LIBRARY_ECL}
|
||||
${ERT_LIBRARY_ECL_WELL}
|
||||
${ERT_LIBRARY_GEOMETRY}
|
||||
${ERT_LIBRARY_UTIL}
|
||||
)
|
||||
list (APPEND ERT_LIBRARIES ${ERT_LIBRARY})
|
||||
list (APPEND ERT_INCLUDE_DIRS ${ERT_INCLUDE_DIR})
|
||||
|
||||
# if we didn't find any files, then don't proceed through the entire dependency list
|
||||
include (FindPackageHandleStandardArgs)
|
||||
if (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
|
||||
find_package_handle_standard_args (ERT
|
||||
DEFAULT_MSG
|
||||
ERT_INCLUDE_DIR ERT_LIBRARY
|
||||
)
|
||||
# clear the cache so the find probe is attempted again if files becomes
|
||||
# available (only upon a unsuccessful *compile* should we disable further
|
||||
# probing)
|
||||
set (HAVE_ERT)
|
||||
unset (HAVE_ERT CACHE)
|
||||
return ()
|
||||
endif (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
|
||||
|
||||
# these system variables are probed for, and used in HEADER files (sic)
|
||||
list (APPEND ERT_CONFIG_VARS
|
||||
HAVE_ISFINITE
|
||||
HAVE_GLOB
|
||||
HAVE_FORK
|
||||
HAVE_GETUID
|
||||
HAVE_LOCKF
|
||||
HAVE_OPENDIR
|
||||
HAVE_PROC
|
||||
HAVE_READLINKAT
|
||||
HAVE_SYMLINK
|
||||
HAVE_VA_COPY
|
||||
)
|
||||
include (CheckSymbolExists)
|
||||
include (CheckFunctionExists)
|
||||
check_symbol_exists (isfinite math.h HAVE_ISFINITE)
|
||||
check_function_exists (glob HAVE_GLOB)
|
||||
check_function_exists (fork HAVE_FORK)
|
||||
check_function_exists (getuid HAVE_GETUID)
|
||||
check_function_exists (lockf HAVE_LOCKF)
|
||||
check_function_exists (opendir HAVE_OPENDIR)
|
||||
check_function_exists (readlinkat HAVE_READLINKAT)
|
||||
check_function_exists (symlink HAVE_SYMLINK)
|
||||
check_symbol_exists (va_copy stdarg.h HAVE_VA_COPY)
|
||||
|
||||
if (UNIX)
|
||||
set (HAVE_PROC 1)
|
||||
else (UNIX)
|
||||
set (HAVE_PROC)
|
||||
endif (UNIX)
|
||||
|
||||
# dependencies
|
||||
|
||||
# parallel programming
|
||||
include (UseOpenMP)
|
||||
find_openmp (ERT)
|
||||
|
||||
# compression library
|
||||
find_package (ZLIB ${ERT_QUIET})
|
||||
if (ZLIB_FOUND)
|
||||
list (APPEND ERT_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
|
||||
list (APPEND ERT_LIBRARIES ${ZLIB_LIBRARIES})
|
||||
endif (ZLIB_FOUND)
|
||||
|
||||
# numerics
|
||||
find_package (BLAS ${ERT_QUIET})
|
||||
if (BLAS_FOUND)
|
||||
list (APPEND ERT_INCLUDE_DIRS ${BLAS_INCLUDE_DIRS})
|
||||
list (APPEND ERT_LIBRARIES ${BLAS_LIBRARIES})
|
||||
list (APPEND ERT_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
|
||||
endif (BLAS_FOUND)
|
||||
find_package (LAPACK ${ERT_QUIET})
|
||||
if (LAPACK_FOUND)
|
||||
list (APPEND ERT_INCLUDE_DIRS ${LAPACK_INCLUDE_DIRS})
|
||||
list (APPEND ERT_LIBRARIES ${LAPACK_LIBRARIES})
|
||||
list (APPEND ERT_LINKER_FLAGS ${LAPACK_LINKER_FLAGS})
|
||||
endif (LAPACK_FOUND)
|
||||
|
||||
# math library (should exist on all unices; automatically linked on Windows)
|
||||
if (UNIX)
|
||||
find_library (MATH_LIBRARY
|
||||
NAMES "m"
|
||||
)
|
||||
list (APPEND ERT_LIBRARIES ${MATH_LIBRARY})
|
||||
endif (UNIX)
|
||||
|
||||
# if shared libraries are disabled on linux, explcitly linking to the
|
||||
# pthreads library is required by ERT
|
||||
find_package(Threads ${ERT_QUIET})
|
||||
if (CMAKE_THREAD_LIBS_INIT)
|
||||
list (APPEND ERT_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
# Platform specific library where dlopen with friends lives
|
||||
list (APPEND ERT_LIBRARIES ${CMAKE_DL_LIBS})
|
||||
|
||||
# since OpenMP often implies pthreads, we need to tidy up
|
||||
# (last instance of library must be left standing, thus reversing that
|
||||
# list before removing duplicates)
|
||||
include (Duplicates)
|
||||
remove_dup_deps (ERT)
|
||||
|
||||
# see if we can compile a minimum example
|
||||
# CMake logical test doesn't handle lists (sic)
|
||||
if (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
|
||||
include (CMakePushCheckState)
|
||||
include (CheckCSourceCompiles)
|
||||
cmake_push_check_state ()
|
||||
set (CMAKE_REQUIRED_INCLUDES ${ERT_INCLUDE_DIR})
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${ERT_LIBRARIES})
|
||||
check_c_source_compiles (
|
||||
"#include <ert/ecl/ecl_util.h>
|
||||
int main (void) {
|
||||
bool ok;
|
||||
ok = ecl_util_fmt_file (\"foo.bar\", &ok);
|
||||
return 0;
|
||||
}" HAVE_ERT)
|
||||
cmake_pop_check_state ()
|
||||
else (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
|
||||
# clear the cache so the find probe is attempted again if files becomes
|
||||
# available (only upon a unsuccessful *compile* should we disable further
|
||||
# probing)
|
||||
set (HAVE_ERT)
|
||||
unset (HAVE_ERT CACHE)
|
||||
endif (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
|
||||
|
||||
# if the test program didn't compile, but was required to do so, bail
|
||||
# out now and display an error; otherwise limp on
|
||||
find_package_handle_standard_args (ERT
|
||||
DEFAULT_MSG
|
||||
ERT_INCLUDE_DIR ERT_LIBRARY HAVE_ERT
|
||||
)
|
@ -1,84 +0,0 @@
|
||||
# Look for the cjson library; will probably newer be found.
|
||||
# If found, it sets these variables:
|
||||
#
|
||||
# CJSON_INCLUDE_DIRS Header file directories
|
||||
# CJSON_LIBRARIES Archive/shared objects
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
if ((NOT CJSON_ROOT) AND OPM_PARSER_ROOT)
|
||||
set( CJSON_ROOT ${OPM_PARSER_ROOT})
|
||||
endif()
|
||||
|
||||
if (CJSON_ROOT)
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
else (CJSON_ROOT)
|
||||
set (_no_default_path "")
|
||||
endif (CJSON_ROOT)
|
||||
|
||||
|
||||
find_path (CJSON_INCLUDE_DIR
|
||||
NAMES "cjson/cJSON.h"
|
||||
HINTS "${CJSON_ROOT}"
|
||||
PATH_SUFFIXES "include" "opm/json"
|
||||
DOC "Path to cjson library header files")
|
||||
|
||||
# find out the size of a pointer. this is required to only search for
|
||||
# libraries in the directories relevant for the architecture
|
||||
if (CMAKE_SIZEOF_VOID_P)
|
||||
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||
endif (CMAKE_SIZEOF_VOID_P)
|
||||
|
||||
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PROJECT_BINARY_DIR}")
|
||||
|
||||
find_library (CJSON_LIBRARY
|
||||
NAMES "cjson"
|
||||
HINTS "${CJSON_ROOT}"
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
"opm/json"
|
||||
DOC "Path to cjson library archive/shared object files")
|
||||
|
||||
# setup list of all required libraries to link with cjson
|
||||
set (CJSON_INCLUDE_DIRS ${CJSON_INCLUDE_DIR})
|
||||
set (CJSON_LIBRARIES ${CJSON_LIBRARY})
|
||||
|
||||
# math library (should exist on all unices; automatically linked on Windows)
|
||||
if (UNIX)
|
||||
find_library (MATH_LIBRARY NAMES "m")
|
||||
list (APPEND CJSON_LIBRARIES ${MATH_LIBRARY})
|
||||
endif (UNIX)
|
||||
|
||||
# see if we can compile a minimum example
|
||||
# CMake logical test doesn't handle lists (sic)
|
||||
if (NOT (CJSON_INCLUDE_DIRS MATCHES "-NOTFOUND" OR CJSON_LIBRARIES MATCHES "-NOTFOUND"))
|
||||
include (CMakePushCheckState)
|
||||
include (CheckCSourceCompiles)
|
||||
cmake_push_check_state ()
|
||||
set (CMAKE_REQUIRED_INCLUDES ${CJSON_INCLUDE_DIRS})
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${CJSON_LIBRARIES})
|
||||
|
||||
check_c_source_compiles (
|
||||
"#include <stdlib.h>
|
||||
#include <cjson/cJSON.h>
|
||||
int main (void) {
|
||||
cJSON root;
|
||||
return 0;
|
||||
}" HAVE_CJSON)
|
||||
cmake_pop_check_state ()
|
||||
else ()
|
||||
# clear the cache so the find probe is attempted again if files becomes
|
||||
# available (only upon a unsuccessful *compile* should we disable further
|
||||
# probing)
|
||||
set (HAVE_CJSON)
|
||||
unset (HAVE_CJSON CACHE)
|
||||
endif ()
|
||||
|
||||
# if the test program didn't compile, but was required to do so, bail
|
||||
# out now and display an error; otherwise limp on
|
||||
set (CJSON_FIND_REQUIRED ${cjson_FIND_REQUIRED})
|
||||
set (CJSON_FIND_QUIETLY ${cjson_FIND_QUIETLY})
|
||||
find_package_handle_standard_args (CJSON
|
||||
DEFAULT_MSG
|
||||
CJSON_INCLUDE_DIRS CJSON_LIBRARIES HAVE_CJSON
|
||||
)
|
||||
set (cjson_FOUND ${CJSON_FOUND})
|
@ -1,166 +0,0 @@
|
||||
# Find the OPM Eclipse input parser.
|
||||
#
|
||||
# Set the cache variable OPM_PARSER_ROOT to the install location of the
|
||||
# library, or OPM_ROOT to the parent directory of the build tree.
|
||||
#
|
||||
# If found, it sets these variables:
|
||||
#
|
||||
# HAVE_OPM_PARSER Defined if a test program compiled
|
||||
# OPM_PARSER_INCLUDE_DIRS Header file directories
|
||||
# OPM_PARSER_LIBRARIES Archives and shared objects
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
# variables to pass on to other packages
|
||||
if (FIND_QUIETLY)
|
||||
set (OPM_PARSER_QUIET "QUIET")
|
||||
else ()
|
||||
set (OPM_PARSER_QUIET "")
|
||||
endif ()
|
||||
|
||||
# use lowercase versions of the variables if those are set
|
||||
if (opm-parser_ROOT)
|
||||
set (OPM_PARSER_ROOT ${opm-parser_ROOT})
|
||||
endif ()
|
||||
if (opm_ROOT)
|
||||
set (OPM_ROOT ${opm_ROOT})
|
||||
endif ()
|
||||
|
||||
# inherit "suite" root if not specifically set for this library
|
||||
if ((NOT OPM_PARSER_ROOT) AND OPM_ROOT)
|
||||
set (OPM_PARSER_ROOT "${OPM_ROOT}/opm-parser")
|
||||
endif ()
|
||||
|
||||
# Detect the build dir suffix or subdirectory
|
||||
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PROJECT_BINARY_DIR}")
|
||||
|
||||
# if a root is specified, then don't search in system directories
|
||||
# or in relative directories to this one
|
||||
if (OPM_PARSER_ROOT)
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
set (_opm_parser_source "")
|
||||
set (_opm_parser_build "")
|
||||
else ()
|
||||
set (_no_default_path "")
|
||||
set (_opm_parser_source
|
||||
"${PROJECT_SOURCE_DIR}/../opm-parser")
|
||||
set (_opm_parser_build
|
||||
"${PROJECT_BINARY_DIR}/../opm-parser"
|
||||
"${PROJECT_BINARY_DIR}/../opm-parser${BUILD_DIR_SUFFIX}"
|
||||
"${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}")
|
||||
endif ()
|
||||
|
||||
# use this header as signature
|
||||
find_path (OPM_PARSER_INCLUDE_DIR
|
||||
NAMES "opm/parser/eclipse/Parser/Parser.hpp"
|
||||
HINTS "${OPM_PARSER_ROOT}"
|
||||
PATHS ${_opm_parser_source}
|
||||
PATH_SUFFIXES "include"
|
||||
DOC "Path to OPM parser header files"
|
||||
${_no_default_path} )
|
||||
|
||||
# backup: if we didn't find any headers there, but a CMakeCache.txt,
|
||||
# then it is probably a build directory; read the CMake cache of
|
||||
# opm-parser to figure out where the source directory is
|
||||
if ((NOT OPM_PARSER_INCLUDE_DIR) AND
|
||||
(OPM_PARSER_ROOT AND (EXISTS "${OPM_PARSER_ROOT}/CMakeCache.txt")))
|
||||
set (_regex "^OPMParser_SOURCE_DIR:STATIC=\(.*\)$")
|
||||
file (STRINGS
|
||||
"${OPM_PARSER_ROOT}/CMakeCache.txt"
|
||||
_cache_entry
|
||||
REGEX "${_regex}")
|
||||
string(REGEX REPLACE "${_regex}" "\\1"
|
||||
OPM_PARSER_INCLUDE_DIR
|
||||
"${_cache_entry}")
|
||||
if (OPM_PARSER_INCLUDE_DIR)
|
||||
set (OPM_PARSER_INCLUDE_DIR "${OPM_PARSER_INCLUDE_DIR}"
|
||||
CACHE PATH "Path to OPM parser header files" FORCE)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# find out the size of a pointer. this is required to only search for
|
||||
# libraries in the directories relevant for the architecture
|
||||
if (CMAKE_SIZEOF_VOID_P)
|
||||
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||
endif ()
|
||||
|
||||
# these libraries constitute the parser core
|
||||
find_library (OPM_PARSER_LIBRARY
|
||||
NAMES "Parser"
|
||||
HINTS "${OPM_PARSER_ROOT}"
|
||||
PATHS ${_opm_parser_build}
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
"opm/parser/eclipse"
|
||||
DOC "Path to OPM parser library archive/shared object files"
|
||||
${_no_default_path} )
|
||||
|
||||
# find the OPM-parser wrapper library around cJSON
|
||||
find_library (OPM_JSON_LIBRARY
|
||||
NAMES "opm-json"
|
||||
HINTS "${OPM_PARSER_ROOT}"
|
||||
PATHS ${_opm_parser_build}
|
||||
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
"opm/json"
|
||||
DOC "Path to OPM JSON library archive/shared object files"
|
||||
${_no_default_path} )
|
||||
|
||||
# get the prerequisite ERT libraries
|
||||
if (NOT ERT_FOUND)
|
||||
find_package(ERT ${OPM_PARSER_QUIET})
|
||||
endif ()
|
||||
|
||||
# get the prerequisite CJSON library
|
||||
if (NOT CJSON_FOUND)
|
||||
find_package(cjson ${OPM_PARSER_QUIET})
|
||||
endif ()
|
||||
|
||||
# get the prerequisite Boost libraries
|
||||
find_package(Boost 1.44.0 COMPONENTS filesystem date_time system unit_test_framework regex ${OPM_PARSER_QUIET})
|
||||
|
||||
if (CJSON_FOUND AND ERT_FOUND AND Boost_FOUND AND
|
||||
OPM_PARSER_LIBRARY AND OPM_JSON_LIBRARY AND OPM_PARSER_INCLUDE_DIR)
|
||||
# setup list of all required libraries to link with opm-parser. notice that
|
||||
# we use the plural form to get *all* the libraries needed by cjson
|
||||
set (opm-parser_INCLUDE_DIRS
|
||||
${OPM_PARSER_INCLUDE_DIR}
|
||||
${CJSON_INCLUDE_DIRS}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${ERT_INCLUDE_DIRS})
|
||||
|
||||
set (opm-parser_LIBRARIES
|
||||
${OPM_PARSER_LIBRARY}
|
||||
${OPM_JSON_LIBRARY}
|
||||
${CJSON_LIBRARIES}
|
||||
${Boost_LIBRARIES}
|
||||
${ERT_LIBRARIES})
|
||||
|
||||
# see if we can compile a minimum example
|
||||
# CMake logical test doesn't handle lists (sic)
|
||||
include (CMakePushCheckState)
|
||||
include (CheckCSourceCompiles)
|
||||
cmake_push_check_state ()
|
||||
set (CMAKE_REQUIRED_INCLUDES ${opm-parser_INCLUDE_DIRS})
|
||||
set (CMAKE_REQUIRED_LIBRARIES ${opm-parser_LIBRARIES})
|
||||
|
||||
check_cxx_source_compiles (
|
||||
"#include <cstdlib>
|
||||
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
||||
|
||||
int main (void) {
|
||||
return EXIT_SUCCESS;
|
||||
}" HAVE_OPM_PARSER)
|
||||
cmake_pop_check_state ()
|
||||
endif()
|
||||
|
||||
# if the test program didn't compile, but was required to do so, bail
|
||||
# out now and display an error; otherwise limp on
|
||||
set (OPM_PARSER_FIND_REQUIRED ${opm-parser_FIND_REQUIRED})
|
||||
find_package_handle_standard_args (opm-parser
|
||||
DEFAULT_MSG
|
||||
opm-parser_INCLUDE_DIRS opm-parser_LIBRARIES HAVE_OPM_PARSER
|
||||
)
|
||||
|
||||
set (opm-parser_CONFIG_VARS "HAVE_OPM_PARSER;HAVE_REGEX")
|
||||
set (opm-parser_FOUND ${OPM-PARSER_FOUND})
|
||||
|
||||
mark_as_advanced(opm-parser_LIBRARIES opm-parser_INCLUDE_DIRS OPM-PARSER_FOUND)
|
@ -1,165 +0,0 @@
|
||||
# translate a list of libraries into a command-line that can be passed to the
|
||||
# compiler/linker. first parameter is the name of the variable that will
|
||||
# receive this list, the rest is considered the list of libraries
|
||||
function (linker_cmdline what INTO outvar FROM)
|
||||
# if we are going to put these in regexps, we must escape period
|
||||
string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}")
|
||||
string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
string (REPLACE "." "\\." esc_ar_pref "${CMAKE_STATIC_LIBRARY_PREFIX}")
|
||||
string (REPLACE "." "\\." esc_ar_suff "${CMAKE_STATIC_LIBRARY_PREFIX}")
|
||||
|
||||
# CMake loves absolute paths, whereas libtool won't have any of it!
|
||||
# (you get an error message about argument not parsed). translate each
|
||||
# of the libraries into a linker option
|
||||
set (deplib_list "")
|
||||
foreach (deplib IN LISTS ARGN)
|
||||
# starts with a hyphen already? then just add it
|
||||
string (SUBSTRING ${deplib} 0 1 dash)
|
||||
if (${dash} STREQUAL "-")
|
||||
list (APPEND deplib_list ${deplib})
|
||||
else (${dash} STREQUAL "-")
|
||||
# otherwise, parse the name into a directory and a name
|
||||
get_filename_component (deplib_dir ${deplib} PATH)
|
||||
get_filename_component (deplib_orig ${deplib} NAME)
|
||||
string (REGEX REPLACE
|
||||
"^${esc_dl_pref}(.*)${esc_dl_suff}$"
|
||||
"\\1"
|
||||
deplib_name
|
||||
${deplib_orig}
|
||||
)
|
||||
string (REGEX REPLACE
|
||||
"^${esc_ar_pref}(.*)${esc_ar_suff}$"
|
||||
"\\1"
|
||||
deplib_name
|
||||
${deplib_name}
|
||||
)
|
||||
# directory and name each on their own; this is somewhat
|
||||
# unsatisfactory because it may be that a system dir is specified
|
||||
# by an earlier directory and you start picking up libraries from
|
||||
# there instead of the "closest" path here. also, the soversion
|
||||
# is more or less lost. remove system default path, to lessen the
|
||||
# chance that we pick the wrong library
|
||||
if (NOT ((deplib_dir STREQUAL "/usr/lib") OR
|
||||
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
|
||||
list (APPEND deplib_list "-L${deplib_dir}")
|
||||
endif (NOT ((deplib_dir STREQUAL "/usr/lib") OR
|
||||
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
|
||||
# if there was no translation of the name, the library is named
|
||||
# unconventionally (.so.3gf, I'm looking at you), so pass this
|
||||
# name unmodified to the linker switch
|
||||
if (deplib_orig STREQUAL deplib_name)
|
||||
list (APPEND deplib_list "-l:${deplib_orig}")
|
||||
else (deplib_orig STREQUAL deplib_name)
|
||||
list (APPEND deplib_list "-l${deplib_name}")
|
||||
endif (deplib_orig STREQUAL deplib_name)
|
||||
endif (${dash} STREQUAL "-")
|
||||
endforeach (deplib)
|
||||
# caller determines whether we want it returned as a list or a string
|
||||
if ("${what}" STREQUAL "LIST")
|
||||
set (${outvar} ${deplib_list})
|
||||
else ("${what}" STREQUAL "LIST")
|
||||
set (${outvar} "${deplib_list}")
|
||||
string (REPLACE ";" " " ${outvar} "${${outvar}}")
|
||||
endif ("${what}" STREQUAL "LIST")
|
||||
set (${outvar} "${${outvar}}" PARENT_SCOPE)
|
||||
endfunction (linker_cmdline what INTO outvar FROM)
|
||||
|
||||
function (configure_la name target)
|
||||
if (NOT (UNIX OR MSYS OR MINGW))
|
||||
return ()
|
||||
endif (NOT (UNIX OR MSYS OR MINGW))
|
||||
|
||||
# these generic variables are initialized from the project info
|
||||
set (current "${${name}_VERSION_MAJOR}")
|
||||
set (age "${${name}_VERSION_MINOR}")
|
||||
set (inherited_linker_flags "${${name}_LINKER_FLAGS}")
|
||||
set (dependency_libs "${${name}_LIBRARIES}")
|
||||
|
||||
# translate list of libraries to command line
|
||||
linker_cmdline (LIST INTO dependency_libs FROM ${dependency_libs})
|
||||
|
||||
# convert from CMake list (i.e. semi-colon separated)
|
||||
string (REPLACE ";" " " inherited_linker_flags "${inherited_linker_flags}")
|
||||
string (REPLACE ";" " " dependency_libs "${dependency_libs}")
|
||||
|
||||
# this is the preferred installation path
|
||||
set (libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
# ${name}_LIBRARY_TYPE is either SHARED or STATIC
|
||||
if (${name}_LIBRARY_TYPE STREQUAL "SHARED")
|
||||
set (libprefix "${CMAKE_SHARED_LIBRARY_PREFIX}")
|
||||
set (libsuffix "${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
set (libname "${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX}")
|
||||
# only Unix has soversion in library names
|
||||
if (UNIX)
|
||||
set (dlname "${libname}.${current}")
|
||||
set (library_names "${libname}.${current}.${age} ${libname}.${current} ${libname}")
|
||||
else (UNIX)
|
||||
set (dlname "${libname}")
|
||||
set (library_names "${libname}")
|
||||
endif (UNIX)
|
||||
set (old_library "")
|
||||
else (${name}_LIBRARY_TYPE STREQUAL "SHARED")
|
||||
set (dlname "")
|
||||
set (library_names "")
|
||||
set (old_library "${CMAKE_STATIC_LIBRARY_PREFIX}${target}${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endif (${name}_LIBRARY_TYPE STREQUAL "SHARED")
|
||||
|
||||
# get the version of libtool installed on the system; this is
|
||||
# necessary because libtool checks that the file contains its own
|
||||
# signature(!)
|
||||
if (NOT libtool_MAIN)
|
||||
find_file (
|
||||
libtool_MAIN
|
||||
ltmain.sh
|
||||
PATHS /usr
|
||||
PATH_SUFFIXES share/libtool/config/
|
||||
DOC "Location of libtool"
|
||||
)
|
||||
mark_as_advanced (libtool_MAIN)
|
||||
# notify the user if it not found after we explicitly searched
|
||||
if (NOT libtool_MAIN)
|
||||
message (STATUS "Libtool not found!")
|
||||
endif (NOT libtool_MAIN)
|
||||
endif (NOT libtool_MAIN)
|
||||
if (libtool_MAIN)
|
||||
file (STRINGS
|
||||
${libtool_MAIN}
|
||||
ltversion_STRING
|
||||
REGEX "^VERSION=\".*\""
|
||||
)
|
||||
endif (libtool_MAIN)
|
||||
if (ltversion_STRING)
|
||||
string (REGEX REPLACE
|
||||
"^VERSION=\"?(.*)\"?"
|
||||
"\\1"
|
||||
ltversion
|
||||
${ltversion_STRING}
|
||||
)
|
||||
endif (ltversion_STRING)
|
||||
|
||||
# assume that we are in cmake/Modules, and that the template have been
|
||||
# put in cmake/Templates. we cannot use CMAKE_CURRENT_LIST_DIR because
|
||||
# this is in a function, and we cannot know who's calling us
|
||||
set (templ_dir "${OPM_MACROS_ROOT}/cmake/Templates")
|
||||
|
||||
|
||||
# only write an .la if libtool is found; otherwise we have no use
|
||||
# for it.
|
||||
if (ltversion)
|
||||
set (la_file "lib${target}.la")
|
||||
message (STATUS "Writing libtool archive for ${target}")
|
||||
configure_file (
|
||||
${templ_dir}/la.in
|
||||
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${la_file}
|
||||
@ONLY@
|
||||
)
|
||||
else (ltversion)
|
||||
set (la_file "")
|
||||
endif (ltversion)
|
||||
|
||||
# return this variable to the caller
|
||||
if (ARGV2)
|
||||
set (${ARGV2} "${la_file}" PARENT_SCOPE)
|
||||
endif (ARGV2)
|
||||
endfunction (configure_la target)
|
@ -1,149 +0,0 @@
|
||||
# - Helper routines for opm-core like projects
|
||||
|
||||
include (LibtoolArchives) # linker_cmdline
|
||||
|
||||
# convert a list back to a command-line string
|
||||
function (unseparate_args var_name prefix value)
|
||||
separate_arguments (value)
|
||||
foreach (item IN LISTS value)
|
||||
set (prefixed_item "${prefix}${item}")
|
||||
if (${var_name})
|
||||
set (${var_name} "${${var_name}} ${prefixed_item}")
|
||||
else (${var_name})
|
||||
set (${var_name} "${prefixed_item}")
|
||||
endif (${var_name})
|
||||
endforeach (item)
|
||||
set (${var_name} "${${var_name}}" PARENT_SCOPE)
|
||||
endfunction (unseparate_args var_name prefix value)
|
||||
|
||||
# wrapper to set variables in pkg-config file
|
||||
function (configure_pc_file name source dest prefix libdir includedir)
|
||||
# escape set of standard strings
|
||||
unseparate_args (includes "-I" "${${name}_INCLUDE_DIRS}")
|
||||
unseparate_args (defs "" "${${name}_DEFINITIONS}")
|
||||
linker_cmdline (STRING INTO libs FROM ${${name}_LIBRARIES})
|
||||
|
||||
# necessary to make these variables visible to configure_file
|
||||
set (name "${${name}_NAME}")
|
||||
set (description "${${name}_DESCRIPTION}")
|
||||
set (major "${${name}_VERSION_MAJOR}")
|
||||
set (minor "${${name}_VERSION_MINOR}")
|
||||
set (target "${${name}_LIBRARY}")
|
||||
linker_cmdline (STRING INTO target from ${target})
|
||||
|
||||
configure_file (${source} ${dest} @ONLY)
|
||||
endfunction (configure_pc_file name source dist prefix libdir includedir)
|
||||
|
||||
function (configure_cmake_file name variant version)
|
||||
# declarative list of the variable names that are used in the template
|
||||
# and that must be defined in the project to be exported
|
||||
set (variable_suffices
|
||||
DESCRIPTION
|
||||
VERSION
|
||||
DEFINITIONS
|
||||
INCLUDE_DIRS
|
||||
LIBRARY_DIRS
|
||||
LINKER_FLAGS
|
||||
CONFIG_VARS
|
||||
LIBRARY
|
||||
LIBRARIES
|
||||
TARGET
|
||||
)
|
||||
|
||||
# set these variables temporarily (this is in a function scope) so
|
||||
# they are available to the template (only)
|
||||
foreach (suffix IN LISTS variable_suffices)
|
||||
set (opm-project_${suffix} "${${name}_${suffix}}")
|
||||
endforeach (suffix)
|
||||
set (opm-project_NAME "${${name}_NAME}")
|
||||
|
||||
# make the file substitutions
|
||||
configure_file (
|
||||
${template_dir}/opm-project-config${version}.cmake.in
|
||||
${PROJECT_BINARY_DIR}/${${name}_NAME}-${variant}${version}.cmake
|
||||
@ONLY
|
||||
)
|
||||
endfunction (configure_cmake_file name)
|
||||
|
||||
# installation of CMake modules to help user programs locate the library
|
||||
function (opm_cmake_config name)
|
||||
# assume that the template is located in cmake/Templates (cannot use
|
||||
# the current directory since this is in a function and the directory
|
||||
# at runtime not at definition will be used
|
||||
set (template_dir "${OPM_MACROS_ROOT}/cmake/Templates")
|
||||
|
||||
# write configuration file to locate library
|
||||
configure_cmake_file (${name} "config" "")
|
||||
configure_cmake_file (${name} "config" "-version")
|
||||
configure_vars (
|
||||
FILE CMAKE "${PROJECT_BINARY_DIR}/${${name}_NAME}-config.cmake"
|
||||
APPEND "${${name}_CONFIG_VARS}"
|
||||
)
|
||||
|
||||
# config-mode .pc file; use this to find the build tree
|
||||
configure_pc_file (
|
||||
${name}
|
||||
${template_dir}/opm-project.pc.in
|
||||
${PROJECT_BINARY_DIR}/${${name}_NAME}.pc
|
||||
${PROJECT_BINARY_DIR}
|
||||
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
|
||||
${PROJECT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# replace the build directory with the target directory in the
|
||||
# variables that contains build paths
|
||||
string (REPLACE
|
||||
"${PROJECT_SOURCE_DIR}"
|
||||
"${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}"
|
||||
${name}_INCLUDE_DIRS
|
||||
"${${name}_INCLUDE_DIRS}"
|
||||
)
|
||||
string (REPLACE
|
||||
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}"
|
||||
${name}_LIBRARY
|
||||
"${${name}_LIBRARY}"
|
||||
)
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
|
||||
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}"
|
||||
)
|
||||
# create a config mode file which targets the install directory instead
|
||||
# of the build directory (using the same input template)
|
||||
configure_cmake_file (${name} "install" "")
|
||||
configure_vars (
|
||||
FILE CMAKE "${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake"
|
||||
APPEND "${${name}_CONFIG_VARS}"
|
||||
)
|
||||
# this file gets copied to the final installation directory
|
||||
install (
|
||||
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake
|
||||
DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
|
||||
RENAME ${${name}_NAME}-config.cmake
|
||||
)
|
||||
# assume that there exists a version file already
|
||||
install (
|
||||
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-config-version.cmake
|
||||
DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
|
||||
)
|
||||
|
||||
# find-mode .pc file; use this to locate system installation
|
||||
configure_pc_file (
|
||||
${name}
|
||||
${template_dir}/opm-project.pc.in
|
||||
${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
|
||||
${CMAKE_INSTALL_PREFIX}
|
||||
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}
|
||||
${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}
|
||||
)
|
||||
|
||||
# put this in the right system location; if we have binaries then it
|
||||
# should go in the arch-specific lib/ directory, otherwise use the
|
||||
# common/noarch lib/ directory (these targets come from UseMultiArch)
|
||||
include(UseMultiArch)
|
||||
set (_pkg_dir ${CMAKE_INSTALL_LIBDIR})
|
||||
install (
|
||||
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${_pkg_dir}/pkgconfig${${name}_VER_DIR}/
|
||||
RENAME ${${name}_NAME}.pc
|
||||
)
|
||||
endfunction (opm_cmake_config name)
|
@ -1,108 +0,0 @@
|
||||
# - Get compiler version
|
||||
|
||||
# probe the GCC version, returns empty string if GCC is not compiler
|
||||
function (get_gcc_version language ver_name)
|
||||
if(CMAKE_${language}_COMPILER_ID STREQUAL GNU)
|
||||
# exec_program is deprecated, but execute_process does't work :-(
|
||||
exec_program (${CMAKE_${language}_COMPILER}
|
||||
ARGS ${CMAKE_${language}_COMPILER_ARG1} -dumpversion
|
||||
OUTPUT_VARIABLE _version
|
||||
)
|
||||
set (${ver_name} ${_version} PARENT_SCOPE)
|
||||
else (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
|
||||
set (${ver_name} "" PARENT_SCOPE)
|
||||
endif (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
|
||||
endfunction (get_gcc_version ver_name)
|
||||
|
||||
# less reliable, but includes the patch number
|
||||
function (get_gcc_patch language ver_name)
|
||||
if(CMAKE_${language}_COMPILER_ID STREQUAL GNU)
|
||||
# exec_program is deprecated, but execute_process does't work :-(
|
||||
exec_program (${CMAKE_${language}_COMPILER}
|
||||
ARGS ${CMAKE_${language}_COMPILER_ARG1} --version
|
||||
OUTPUT_VARIABLE _version
|
||||
)
|
||||
# split multi-line string into list
|
||||
if (WIN32)
|
||||
string (REPLACE "\r\n" ";" _version "${_version}")
|
||||
else (WIN32)
|
||||
string (REPLACE "\n" ";" _version "${_version}")
|
||||
endif (WIN32)
|
||||
# only keep first line
|
||||
list (GET _version 0 _version)
|
||||
# extract version number from it (this is the fragile part)
|
||||
string (REGEX REPLACE "^[^\\(]+(\\([^\\)]*\\))?[\ \t]*([0-9]+\\.[0-9]+\\.[0-9]+)(.*\\(.*\\))?" "\\2" _version "${_version}")
|
||||
# return this to the caller
|
||||
set (${ver_name} ${_version} PARENT_SCOPE)
|
||||
else (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
|
||||
set (${ver_name} "" PARENT_SCOPE)
|
||||
endif (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
|
||||
endfunction (get_gcc_patch language ver_name)
|
||||
|
||||
function (compiler_info)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
get_gcc_patch (CXX version)
|
||||
message (STATUS "GNU C++ compiler version: ${version}")
|
||||
endif (CMAKE_COMPILER_IS_GNUCXX)
|
||||
endfunction (compiler_info)
|
||||
|
||||
function (get_ld_version ver_name)
|
||||
# run linker to get the version number. interestingly, this option works
|
||||
# (for our purposes) on all major platforms (Linux, Mac OS X and Windows);
|
||||
# it returns the program version although it may have ended in error
|
||||
exec_program (${CMAKE_LINKER}
|
||||
ARGS "-v"
|
||||
OUTPUT_VARIABLE _version
|
||||
)
|
||||
|
||||
# keep only first line, even on Mac OS X there is no line end
|
||||
list (GET _version 0 _version)
|
||||
|
||||
# format of the version string is platform-specific
|
||||
if (NOT WIN32)
|
||||
if (APPLE)
|
||||
string (REGEX REPLACE ".*, from Apple (.*\)" "\\1" _version "${_version}")
|
||||
else (APPLE)
|
||||
# assuming some GNU toolchain now
|
||||
string (REGEX REPLACE "GNU ([a-zA-Z0-9_]*) (version|\\(.*\\)) ([^\\ ]*).*" "\\1 \\3" _version "${_version}")
|
||||
endif (APPLE)
|
||||
endif (NOT WIN32)
|
||||
|
||||
# return the string to the caller
|
||||
set (${ver_name} "${_version}" PARENT_SCOPE)
|
||||
endfunction (get_ld_version ver_name)
|
||||
|
||||
function (linker_info)
|
||||
get_ld_version (version)
|
||||
message (STATUS "Linker: ${version}")
|
||||
endfunction (linker_info)
|
||||
|
||||
# sets CXX_COMPAT_GCC if we have either GCC or Clang
|
||||
macro (is_compiler_gcc_compatible)
|
||||
# is the C++ compiler clang++?
|
||||
string (TOUPPER "${CMAKE_CXX_COMPILER_ID}" _comp_id)
|
||||
if (_comp_id MATCHES "CLANG")
|
||||
set (CMAKE_COMPILER_IS_CLANGXX TRUE)
|
||||
else ()
|
||||
set (CMAKE_COMPILER_IS_CLANGXX FALSE)
|
||||
endif ()
|
||||
# is the C++ compiler g++ or clang++?
|
||||
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
|
||||
set (CXX_COMPAT_GCC TRUE)
|
||||
else ()
|
||||
set (CXX_COMPAT_GCC FALSE)
|
||||
endif ()
|
||||
# is the C compiler clang?
|
||||
string (TOUPPER "${CMAKE_C_COMPILER_ID}" _comp_id)
|
||||
if (_comp_id MATCHES "CLANG")
|
||||
set (CMAKE_COMPILER_IS_CLANG TRUE)
|
||||
else ()
|
||||
set (CMAKE_COMPILER_IS_CLANG FALSE)
|
||||
endif ()
|
||||
# is the C compiler gcc or clang?
|
||||
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
|
||||
set (C_COMPAT_GCC TRUE)
|
||||
else ()
|
||||
set (C_COMPAT_GCC FALSE)
|
||||
endif ()
|
||||
endmacro (is_compiler_gcc_compatible)
|
@ -1,32 +0,0 @@
|
||||
# - Multiarch support in object code library directories
|
||||
#
|
||||
# This module sets the following variable
|
||||
# CMAKE_INSTALL_LIBDIR to lib, lib64 or lib/x86_64-linux-gnu
|
||||
# depending on the platform; use this path
|
||||
# for platform-specific binaries.
|
||||
#
|
||||
# Note that it will override the results of GNUInstallDirs if included after
|
||||
# that module.
|
||||
|
||||
# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu;
|
||||
# Fedora put module files in lib64/ too, but Debian uses lib/ for that
|
||||
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
# Debian or Ubuntu?
|
||||
if (EXISTS "/etc/debian_version")
|
||||
set (_libdir_def "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
set (_libdir_noarch "lib")
|
||||
else (EXISTS "/etc/debian_version")
|
||||
# 64-bit system?
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set (_libdir_def "lib64")
|
||||
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set (_libdir_def "lib")
|
||||
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
endif (EXISTS "/etc/debian_version")
|
||||
else ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
set (_libdir_def "lib")
|
||||
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
|
||||
|
||||
# let the user override if somewhere else is desirable
|
||||
set (CMAKE_INSTALL_LIBDIR "${_libdir_def}" CACHE PATH "Object code libraries")
|
||||
mark_as_advanced (CMAKE_INSTALL_LIBDIR)
|
@ -1,70 +0,0 @@
|
||||
# - Use OpenMP features
|
||||
#
|
||||
# Synopsis:
|
||||
#
|
||||
# find_openmp (module)
|
||||
#
|
||||
# where:
|
||||
#
|
||||
# module Name of the module to which OpenMP libraries
|
||||
# etc. should be added, e.g. "opm-core".
|
||||
#
|
||||
# Note: Compiler flags are always added globally, to avoid ABI
|
||||
# incompatibility problems.
|
||||
#
|
||||
# It is assumed that the following variables are available
|
||||
#
|
||||
# ${module}_QUIET Verbosity level of the parent's find module
|
||||
# ${module}_LIBRARIES List of libraries to which OpenMP will be added
|
||||
#
|
||||
# Example:
|
||||
# find_openmp (opm-core)
|
||||
# remove_dup_deps (opm-core)
|
||||
|
||||
include (AddOptions)
|
||||
include (UseCompVer)
|
||||
is_compiler_gcc_compatible ()
|
||||
|
||||
macro (find_openmp opm)
|
||||
# default is that OpenMP is not considered to be there; if we set this
|
||||
# to a blank definition, it may be added but it cannot be removed if
|
||||
# it propagates to other projects (someone declares it to be part of
|
||||
# _CONFIG_VARS)
|
||||
set (HAVE_OPENMP)
|
||||
|
||||
# user code can be conservative by setting USE_OPENMP_DEFAULT
|
||||
if (NOT DEFINED USE_OPENMP_DEFAULT)
|
||||
set (USE_OPENMP_DEFAULT ON)
|
||||
endif (NOT DEFINED USE_OPENMP_DEFAULT)
|
||||
option (USE_OPENMP "Enable OpenMP for parallelization" ${USE_OPENMP_DEFAULT})
|
||||
if (USE_OPENMP)
|
||||
|
||||
# enabling OpenMP is supposedly enough to make the compiler link with
|
||||
# the appropriate libraries
|
||||
find_package (OpenMP ${${opm}_QUIET})
|
||||
list (APPEND ${opm}_LIBRARIES ${OpenMP_LIBRARIES})
|
||||
if (OPENMP_FOUND)
|
||||
add_options (C ALL_BUILDS "${OpenMP_C_FLAGS}")
|
||||
add_options (CXX ALL_BUILDS "${OpenMP_CXX_FLAGS}")
|
||||
set (HAVE_OPENMP 1)
|
||||
endif (OPENMP_FOUND)
|
||||
|
||||
# threading library (search for this *after* OpenMP
|
||||
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
find_package (Threads ${${opm}_QUIET})
|
||||
if (CMAKE_USE_PTHREADS_INIT)
|
||||
list (APPEND ${opm}_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif (CMAKE_USE_PTHREADS_INIT)
|
||||
|
||||
else (USE_OPENMP)
|
||||
message (STATUS "OpenMP: disabled")
|
||||
|
||||
# if we don't have OpenMP support, then don't show warnings that these
|
||||
# pragmas are unknown
|
||||
if (CXX_COMPAT_GCC)
|
||||
add_options (ALL_LANGUAGES ALL_BUILDS "-Wno-unknown-pragmas")
|
||||
elseif (MSVC)
|
||||
add_options (ALL_LANGUAGES ALL_BUILDS "-wd4068")
|
||||
endif()
|
||||
endif (USE_OPENMP)
|
||||
endmacro (find_openmp opm)
|
@ -1,8 +0,0 @@
|
||||
function install_headers( header-list prefix )
|
||||
foreach (header in header-list)
|
||||
get_filename_component( path ${header} PATH )
|
||||
file( RELATIVE_PATH rel_path ${PROJECT_SOURCE_DIR} ${path})
|
||||
install ( FILES ${header}
|
||||
DESTINATION ${prefix}/include/${rel_path} )
|
||||
endforeach()
|
||||
endfunction()
|
540
cmake/Scripts/configure
vendored
540
cmake/Scripts/configure
vendored
@ -1,540 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# where is the source tree located by default relative to here
|
||||
srcdir=$(dirname "$(dirname "$(dirname "$0")")")
|
||||
|
||||
# display help text
|
||||
usage () {
|
||||
cat <<EOF
|
||||
Installation directories:
|
||||
--prefix=PREFIX install architecture-independent files in PREFIX
|
||||
[/usr/local]. Note: set DESTDIR=PATH when doing
|
||||
\`make install' to install to a different sysroot.
|
||||
|
||||
Optional Features:
|
||||
--disable-FEATURE do not include FEATURE
|
||||
--disable-gxx11check do not try flag -std=c++11 to enable C++11 features
|
||||
--enable-shared build a shared library [default=yes]
|
||||
--enable-static build a static library [default=no]. Note: only one
|
||||
of the options shared and static may be built.
|
||||
--enable-debug build a non-optimized version of the library
|
||||
[default=no]
|
||||
--disable-runpath do not use RUNPATH in installed library [default=yes]
|
||||
--enable-lto use whole program optimization [default=no]
|
||||
--disable-tests do not compile and enable unit tests [default=yes]
|
||||
--disable-examples do not compile example programs [default=yes]
|
||||
--disable-pch do not use precompiled headers (if buggy compiler)
|
||||
--disable-silent-rules print every compilation statement as executed
|
||||
--enable-system-debug put .debug files in global GDB debug dir
|
||||
[default=yes if prefix=/usr, no otherwise]
|
||||
--enable-parallel process in parallel using MPI [default=no]
|
||||
--enable-openmp activate experimental support for OpenMP
|
||||
--disable-option-checking ignore unrecognized --enable/--with options
|
||||
--enable-underscoring assume Fortran routines have _ suffix [default=no]
|
||||
--enable-ninja use Ninja build generator [default=no]
|
||||
(automatically implies --enable-underscoring)
|
||||
--config-cache Reuse build configuration cache from a previous run
|
||||
|
||||
Optional Packages:
|
||||
--with-alugrid=PATH use the ALUGrid library from a specified location
|
||||
--with-metis=PATH use the METIS graph partitioning library from a specified location
|
||||
--with-boost=PATH use Boost library from a specified location
|
||||
--with-dune=PATH specify parent of all DUNE modules not specified
|
||||
--with-dune-MODULE=PATH use given DUNE module from a specified location
|
||||
--with-opm=PATH specify parent of all OPM modules not specified
|
||||
--with-opm-MODULE=PATH use given OPM module from a specified location
|
||||
--with-superlu=PATH user defined path to SuperLU library
|
||||
--with-umfpack=PATH use UMFPACK/SuiteSparse from a specified location
|
||||
--with-ert=PATH Use ERT libraries
|
||||
--with-tinyxml=PATH use TinyXML library from a specified location
|
||||
(Note: if not found, then a bundled library will
|
||||
be used)
|
||||
--with-cmake=PROGRAM use this program instead of \`cmake' to configure
|
||||
--with-buildname=TEXT description passed to the CDash configuration
|
||||
--with-site=TEXT site passed to the CDash configuration
|
||||
|
||||
Some influential environment variables:
|
||||
CC C compiler command
|
||||
CFLAGS C compiler flags
|
||||
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
|
||||
nonstandard directory <lib dir>
|
||||
LIBS libraries to pass to the linker, e.g. -l<library>
|
||||
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
|
||||
you have headers in a nonstandard directory <include dir>
|
||||
CPP C preprocessor
|
||||
CXX C++ compiler command
|
||||
CXXFLAGS C++ compiler flags
|
||||
CXXCPP C++ preprocessor
|
||||
F77 Fortran 77 compiler command
|
||||
FFLAGS Fortran 77 compiler flags
|
||||
FC Fortran compiler command
|
||||
FCFLAGS Fortran compiler flags
|
||||
CMAKE_COMMAND Executable used to run cmake scripts
|
||||
|
||||
Use these variables to override the choices made by \`configure' or to help
|
||||
it to find libraries and programs with nonstandard names/locations.
|
||||
EOF
|
||||
}
|
||||
|
||||
# report an error regarding the arguments
|
||||
invalid_arg () {
|
||||
cat <<EOF
|
||||
configure: error: unrecognized option: \`$1'
|
||||
Try \`$0 --help' for more information
|
||||
EOF
|
||||
}
|
||||
|
||||
# notify the user that this argument is not known
|
||||
unknown_arg () {
|
||||
cat <<EOF
|
||||
configure: warning: unrecognized option: \`$1'
|
||||
EOF
|
||||
}
|
||||
|
||||
# warn only if option checking is enabled
|
||||
invalid_opt () {
|
||||
if [ "${option_check}" = "yes" ]; then
|
||||
unknown_arg "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# default values
|
||||
prefix=/usr/local
|
||||
#c_compiler=" -DCMAKE_C_COMPILER=cc"
|
||||
c_compiler=
|
||||
c_opts=
|
||||
#cxx_compiler=" -DCMAKE_CXX_COMPILER=c++"
|
||||
cxx_compiler=
|
||||
cxx_opts=
|
||||
#fort_compiler=" -DCMAKE_Fortran_COMPILER=fc"
|
||||
fort_compiler=
|
||||
fort_opts=
|
||||
#buildtype=" -DCMAKE_BUILD_TYPE=Debug"
|
||||
buildtype=
|
||||
#pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
|
||||
pch_use=
|
||||
#use_openmp=" -DUSE_OPENMP=OFF"
|
||||
use_openmp=
|
||||
use_mpi=
|
||||
#silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=OFF"
|
||||
silent_rules=
|
||||
#debug_loc=" -DSYSTEM_DEBUG=OFF"
|
||||
debug_loc=
|
||||
#use_lto=" -DWHOLE_PROG_OPTIM=OFF"
|
||||
use_lto=
|
||||
#use_runpath=" -DUSE_RUNPATH=OFF"
|
||||
use_runpath=
|
||||
#use_tests=" -DBUILD_TESTING=ON"
|
||||
use_tests=
|
||||
#use_samples=" -DBUILD_EXAMPLES=ON"
|
||||
use_samples=
|
||||
#use_ninja="-G\"Unix Makefiles\" "
|
||||
use_ninja=
|
||||
#use_underscoring=" -DUSE_UNDERSCORING=OFF"
|
||||
use_underscoring=
|
||||
# boost_root=""
|
||||
boost_root=
|
||||
boost_libdir=
|
||||
boost_opts=
|
||||
# configuration that is passed on to CTest/CDash
|
||||
buildname=
|
||||
site=
|
||||
# if set, this prevents the previous CMake cache from being deleted
|
||||
config_cache=
|
||||
|
||||
# default is to warn for unknown options, but this can be disabled
|
||||
option_check=yes
|
||||
|
||||
# this variable will get feature options
|
||||
FEATURES=
|
||||
|
||||
# this array will get all variable assignments from command-line
|
||||
VARS=()
|
||||
|
||||
# command that launches cmake; look for 2.8 if available
|
||||
if [ "${CMAKE_COMMAND}" = "" ]; then
|
||||
if [ -x "$(command -v cmake28)" ]; then
|
||||
CMAKE_COMMAND=cmake28
|
||||
else
|
||||
CMAKE_COMMAND=cmake
|
||||
fi
|
||||
fi
|
||||
|
||||
# helper routine
|
||||
uppercase () {
|
||||
echo "$@" | tr "a-z-" "A-Z_"
|
||||
}
|
||||
|
||||
for OPT in "$@"; do
|
||||
case "$OPT" in
|
||||
--*)
|
||||
OPTARG=${OPT#--}
|
||||
# OPTARG now contains everything after double dashes
|
||||
case "${OPTARG}" in
|
||||
config-cache|cache-file=*)
|
||||
# prevent the previous CMake cache from being deleted. The
|
||||
# second option is only here for Dune/autotools compatibility
|
||||
config_cache="1"
|
||||
;;
|
||||
src-dir=*)
|
||||
# allow the user to use these build macros for another
|
||||
# project (so source-dir is not relative to us)
|
||||
srcdir=${OPTARG#*=}
|
||||
;;
|
||||
prefix=*)
|
||||
# remove prefix consisting of everything up to equal sign
|
||||
prefix=${OPTARG#*=}
|
||||
;;
|
||||
help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
with-*)
|
||||
# get the name of the package; everything before equal sign
|
||||
pkgname=${OPTARG%=*}
|
||||
pkgname=${pkgname#with-}
|
||||
# get the location of the package; everyhing after equal sign
|
||||
test -n "${OPTARG#with-${pkgname}}" && pkgloc=${OPTARG#*=} || pkgloc=""
|
||||
# the parameter to this option is an executable program, so
|
||||
# skip the directory test in that case. if we match any of
|
||||
# these special options, then stop further processing (the
|
||||
# argument is not a directory anyway)
|
||||
case "${pkgname}" in
|
||||
cmake)
|
||||
CMAKE_COMMAND="${pkgloc}"
|
||||
continue
|
||||
;;
|
||||
buildname)
|
||||
buildname=" -DBUILDNAME=\"${pkgloc}\""
|
||||
continue
|
||||
;;
|
||||
site)
|
||||
site=" -DSITE=\"${pkgloc}\""
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
# tilde expansion; quote safely before running eval on it
|
||||
eval pkgloc=$(printf "%q" "${pkgloc}")
|
||||
# expand to full path since CMake changes to source directory (!)
|
||||
# this also normalize the path name wrt. not having a trailing slash
|
||||
test -d "${pkgloc}" && pkgloc=$(sh -c "cd \"${pkgloc}\"; pwd")
|
||||
# special aliases
|
||||
case "${pkgname}" in
|
||||
umfpack)
|
||||
pkgname="SuiteSparse"
|
||||
;;
|
||||
tinyxml)
|
||||
pkgname="TinyXML"
|
||||
;;
|
||||
esac
|
||||
# packages need different suffix for their root (sic)
|
||||
case "${pkgname}" in
|
||||
pch)
|
||||
pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
|
||||
rootvar=""
|
||||
;;
|
||||
mpi |\
|
||||
mpi-prefix)
|
||||
# specifying path implies use of package
|
||||
use_mpi=" -DUSE_MPI=ON"
|
||||
# only set prefix if specified, i.e. setting doubles as flag
|
||||
test -n "${pkgloc}" && rootvar="_MPI_PREFIX_PATH" || rootvar=""
|
||||
;;
|
||||
boost)
|
||||
# special handling of this package, see further below
|
||||
boost_root="${pkgloc}"
|
||||
rootvar=""
|
||||
;;
|
||||
boost-libdir)
|
||||
boost_libdir="${pkgloc}"
|
||||
rootvar=""
|
||||
;;
|
||||
alugrid |\
|
||||
eigen3 |\
|
||||
ert |\
|
||||
metis |\
|
||||
superlu |\
|
||||
SuiteSparse |\
|
||||
TinyXML |\
|
||||
opm |\
|
||||
opm-* |\
|
||||
dune |\
|
||||
dune-* |\
|
||||
zlib)
|
||||
rootvar="$(uppercase ${pkgname})_ROOT"
|
||||
rootvar="${rootvar/-/_}"
|
||||
;;
|
||||
*)
|
||||
invalid_opt --with-${pkgname}
|
||||
rootvar=""
|
||||
;;
|
||||
esac
|
||||
# add this to the list of existing features
|
||||
test -n "${rootvar}" && \
|
||||
FEATURES="${FEATURES} \"-D${rootvar}=${pkgloc}\""
|
||||
;;
|
||||
without-* | \
|
||||
disable-*)
|
||||
# get the name of the package
|
||||
pkgname=$OPTARG
|
||||
pkgname=${pkgname#disable-}
|
||||
pkgname=${pkgname#without-}
|
||||
# casing is of course different
|
||||
case "${pkgname}" in
|
||||
option-checking)
|
||||
option_check=no
|
||||
# special flag: don't disable any particular package
|
||||
pkgname=""
|
||||
;;
|
||||
debug)
|
||||
buildtype=" -DCMAKE_BUILD_TYPE=Release"
|
||||
# special flag: don't disable any particular package
|
||||
pkgname=""
|
||||
;;
|
||||
pch)
|
||||
pch_use=" -DPRECOMPILE_HEADERS:BOOL=OFF"
|
||||
pkgname=""
|
||||
;;
|
||||
runpath)
|
||||
use_runpath=" -DUSE_RUNPATH=OFF"
|
||||
pkgname=""
|
||||
;;
|
||||
silent-rules)
|
||||
silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=ON"
|
||||
pkgname=""
|
||||
;;
|
||||
system-debug)
|
||||
debug_loc=" -DSYSTEM_DEBUG=OFF"
|
||||
pkgname=""
|
||||
;;
|
||||
wpo |\
|
||||
lto )
|
||||
use_lto=" -DWHOLE_PROG_OPTIM=OFF"
|
||||
pkgname=""
|
||||
;;
|
||||
openmp)
|
||||
use_openmp=" -DUSE_OPENMP=OFF"
|
||||
pkgname=""
|
||||
;;
|
||||
mpi | \
|
||||
parallel)
|
||||
use_mpi=" -DUSE_MPI=OFF"
|
||||
pkgname=""
|
||||
;;
|
||||
tests)
|
||||
use_tests=" -DBUILD_TESTING=OFF"
|
||||
pkgname=""
|
||||
;;
|
||||
examples)
|
||||
use_samples=" -DBUILD_EXAMPLES=OFF"
|
||||
pkgname=""
|
||||
;;
|
||||
ninja)
|
||||
# just for symmetry with the --enable-ninja option
|
||||
use_ninja=""
|
||||
pkgname=""
|
||||
;;
|
||||
ert |\
|
||||
superlu)
|
||||
pkgname="$(uppercase ${pkgname})"
|
||||
;;
|
||||
openmp)
|
||||
pkgname="OpenMP"
|
||||
;;
|
||||
gxx11check)
|
||||
pkgname="CXX11Features"
|
||||
;;
|
||||
umfpack)
|
||||
pkgname="SuiteSparse"
|
||||
;;
|
||||
tinyxml)
|
||||
pkgname="TinyXML"
|
||||
;;
|
||||
*)
|
||||
invalid_opt --disable-${pkgname}
|
||||
pkgname=""
|
||||
;;
|
||||
esac
|
||||
# only disable packages if the flag refers to a proper one
|
||||
test -n "${pkgname}" && \
|
||||
FEATURES="${FEATURES} -DCMAKE_DISABLE_FIND_PACKAGE_${pkgname}=TRUE"
|
||||
;;
|
||||
enable-*)
|
||||
# what kind of library are we building; shared or static?
|
||||
kind=${OPTARG#enable-}
|
||||
case "${kind}" in
|
||||
system-debug)
|
||||
debug_loc=" -DSYSTEM_DEBUG=ON"
|
||||
# special flag; don't set shared/static
|
||||
shared=""
|
||||
;;
|
||||
openmp)
|
||||
use_openmp=" -DUSE_OPENMP=ON"
|
||||
# special flag; don't set shared/static
|
||||
shared=""
|
||||
;;
|
||||
mpi | \
|
||||
parallel)
|
||||
use_mpi=" -DUSE_MPI=ON"
|
||||
# special flag; don't set shared/static
|
||||
shared=""
|
||||
;;
|
||||
debug)
|
||||
buildtype=" -DCMAKE_BUILD_TYPE=Debug"
|
||||
shared=""
|
||||
;;
|
||||
pch)
|
||||
pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
|
||||
shared=""
|
||||
;;
|
||||
runpath)
|
||||
use_runpath=" -DUSE_RUNPATH=ON"
|
||||
shared=""
|
||||
;;
|
||||
lto)
|
||||
use_lto=" -DWHOLE_PROG_OPTIM=ON"
|
||||
shared=""
|
||||
;;
|
||||
tests)
|
||||
use_tests=" -DBUILD_TESTING=ON"
|
||||
pkgname=""
|
||||
;;
|
||||
examples)
|
||||
use_samples=" -DBUILD_EXAMPLES=ON"
|
||||
pkgname=""
|
||||
;;
|
||||
underscoring)
|
||||
use_underscoring=" -DUSE_UNDERSCORING=ON"
|
||||
pkgname=""
|
||||
;;
|
||||
ninja)
|
||||
# Ninja doesn't support using the Fortran compiler, so
|
||||
# we'll have to resort to making this assumption
|
||||
use_underscoring=" -DUSE_UNDERSCORING=ON"
|
||||
use_ninja="-GNinja "
|
||||
pkgname=""
|
||||
;;
|
||||
# this flag is just for compatibility with the deprecation
|
||||
# flag in DUNE, so we can build without warnings
|
||||
fieldvector-size-is-method)
|
||||
shared=""
|
||||
;;
|
||||
shared)
|
||||
shared="ON"
|
||||
;;
|
||||
static)
|
||||
shared="OFF"
|
||||
;;
|
||||
*)
|
||||
invalid_opt "--enable-${kind}"
|
||||
shared=""
|
||||
;;
|
||||
esac
|
||||
test -n "${shared}" && \
|
||||
FEATURES="${FEATURES} -DBUILD_SHARED_LIBS:BOOL=${shared}"
|
||||
# once we have added this, reset so we don't add again for next opt
|
||||
shared=""
|
||||
;;
|
||||
*)
|
||||
# remove everything *after* the equal sign
|
||||
arg=${OPTARG%=*}
|
||||
invalid_arg "--$arg"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
[A-Za-z0-9_]*=*)
|
||||
# collect for further processing later
|
||||
VARS+=("$OPT")
|
||||
;;
|
||||
*)
|
||||
invalid_arg "$OPT"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# remove all arguments processed by getopts
|
||||
shift $((OPTIND-1))
|
||||
|
||||
# special handling of Boost: if --with-boost-libdir has been used,
|
||||
# then the --with-boost turns into specifying the header directory
|
||||
# and not the search root. this mirrors the functionality in the
|
||||
# Autotools ax_boost_base.m4. necessary because FindBoost in CMake
|
||||
# uses two different variables if you want to specify them separately
|
||||
if [ -n "${boost_libdir}" ]; then
|
||||
boost_opts=" -DBOOST_LIBRARYDIR=\"${boost_libdir}\""
|
||||
if [ -n "${boost_root}" ]; then
|
||||
boost_opts="${boost_opts} -DBOOST_INCLUDEDIR=\"${boost_root}\""
|
||||
fi
|
||||
else
|
||||
if [ -n "${boost_root}" ]; then
|
||||
boost_opts=" -DBOOST_ROOT=\"${boost_root}\""
|
||||
else
|
||||
boost_opts=""
|
||||
fi
|
||||
fi
|
||||
|
||||
# notice the usage of a quoted array: each element will be returned
|
||||
# even with spaces.
|
||||
for a in "${VARS[@]}"; do
|
||||
case "$a" in
|
||||
ACLOCAL_*=*)
|
||||
# remove Autotools-specific variables.
|
||||
;;
|
||||
CC=*)
|
||||
# special processing for compiler options
|
||||
a=${a#CC=}
|
||||
[ -x "$(command -v "$a")" ] && a=$(command -v "$a")
|
||||
c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
CXX=*)
|
||||
a=${a#CXX=}
|
||||
[ -x "$(command -v "$a")" ] && a=$(command -v "$a")
|
||||
cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
CFLAGS=*)
|
||||
a=${a#CFLAGS=}
|
||||
a="${a/\"/\\\"}"
|
||||
c_opts=" -DCMAKE_C_FLAGS=\"$a\" -DCMAKE_C_FLAGS_DEBUG=\"$a\" -DCMAKE_C_FLAGS_RELEASE=\"$a\" "
|
||||
;;
|
||||
CXXFLAGS=*)
|
||||
a=${a#CXXFLAGS=}
|
||||
a="${a/\"/\\\"}"
|
||||
cxx_opts=" -DCMAKE_CXX_FLAGS=\"$a\" -DCMAKE_CXX_FLAGS_DEBUG=\"$a\" -DCMAKE_CXX_FLAGS_RELEASE=\"$a\" "
|
||||
;;
|
||||
FC=*)
|
||||
a=${a#FC=}
|
||||
[ -x "$(command -v "$a")" ] && a=$(command -v "$a")
|
||||
fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
FFLAGS=*)
|
||||
a=${a#FFLAGS=}
|
||||
fort_opts=" -DCMAKE_Fortran_FLAGS=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
*)
|
||||
ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# only wrap in env command if any variable were actually passed
|
||||
[ -n "${ENVVARS}" ] && ENVVARS="env ${ENVVARS} "
|
||||
|
||||
# delete the previous 'CMakeFiles' directory. this prevents an endless
|
||||
# loop if variables that require a full regeneration of the cache are
|
||||
# set (most notably 'CXX' and 'CXX_FLAGS').
|
||||
# For more details, see http://www.cmake.org/Bug/view.php?id=14119
|
||||
if test "$config_cache" = ""; then
|
||||
echo "--- deleting previous CMake files ---"
|
||||
rm -rf CMakeFiles
|
||||
rm -f CMakeCache.txt
|
||||
elif test "$c_compiler$c_opts$cxx_compiler$cxx_opts$fort_compiler$fort_opts" != ""; then
|
||||
echo "--- WARNING '--config-cache' option specified but a compiler was set"
|
||||
echo "--- from the command line. This may lead to an infinite loop!"
|
||||
fi
|
||||
|
||||
# pass everything on to CMake
|
||||
CMDLINE="${ENVVARS}${CMAKE_COMMAND} \"${srcdir}\" ${use_ninja}\"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${use_runpath}${use_tests}${use_samples}${use_underscoring}${c_compiler}${c_opts}${cxx_compiler}${cxx_opts}${fort_compiler}${fort_opts}${boost_opts}${buildname}${site} ${FEATURES}"
|
||||
echo --- calling CMake ---
|
||||
echo "${CMDLINE}"
|
||||
eval exec "${CMDLINE}"
|
@ -1,28 +0,0 @@
|
||||
# - CMake version file for @opm-project_NAME@
|
||||
#
|
||||
# Determine if requested version matches exactly or is compatible with
|
||||
# the installed package. It sets the following variables:
|
||||
#
|
||||
# PACKAGE_VERSION Full provided version string
|
||||
# PACKAGE_VERSION_COMPATIBLE True if version is compatible
|
||||
# PACKAGE_VERSION_EXACT True if version is exact match
|
||||
|
||||
# This file is used by find_package to see if the installed version of a
|
||||
# package can be used by the client, before the main -config.cmake file
|
||||
# is loaded.
|
||||
# see <http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Package_Version_Files>
|
||||
|
||||
# this is the version that is installed
|
||||
set (PACKAGE_VERSION @opm-project_VERSION@)
|
||||
|
||||
# if we wanted this exact version, then everything's fine
|
||||
if (PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
|
||||
set (PACKAGE_VERSION_EXACT TRUE)
|
||||
endif (PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
|
||||
|
||||
# in general, we assume that there is going to be API breakage between
|
||||
# released versions; this will hopefully change in the future
|
||||
## compatible versions
|
||||
#if (NOT PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
||||
# set (PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
#endif (NOT PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
@ -1,66 +0,0 @@
|
||||
# - @opm-project_DESCRIPTION@ config mode
|
||||
#
|
||||
# Defines the following variables:
|
||||
# @opm-project_NAME@_FOUND - true
|
||||
# @opm-project_NAME@_VERSION - version of the @opm-project_NAME@ library found, e.g. 0.2
|
||||
# @opm-project_NAME@_DEFINITIONS - defines to be made on the command line
|
||||
# @opm-project_NAME@_INCLUDE_DIRS - header directories with which to compile
|
||||
# @opm-project_NAME@_LINKER_FLAGS - flags that must be passed to the linker
|
||||
# @opm-project_NAME@_LIBRARIES - names of the libraries with which to link
|
||||
# @opm-project_NAME@_LIBRARY_DIRS - directories in which the libraries are situated
|
||||
#
|
||||
# You should put lines like this in your CMakeLists.txt
|
||||
# set (@opm-project_NAME@_DIR "${PROJECT_BINARY_DIR}/../@opm-project_NAME@" CACHE LOCATION "Build tree of @opm-project_NAME@")
|
||||
# find_package (@opm-project_NAME@)
|
||||
# configure_vars (
|
||||
# FILE CXX "${PROJECT_BINARY_DIR}/config.h"
|
||||
# WRITE ${@opm-project_NAME@_CONFIG_VARS}
|
||||
# )
|
||||
|
||||
# <http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file>
|
||||
|
||||
# propagate these properties from one build system to the other
|
||||
set (@opm-project_NAME@_VERSION "@opm-project_VERSION@")
|
||||
set (@opm-project_NAME@_DEFINITIONS "@opm-project_DEFINITIONS@")
|
||||
set (@opm-project_NAME@_INCLUDE_DIRS "@opm-project_INCLUDE_DIRS@")
|
||||
set (@opm-project_NAME@_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
|
||||
set (@opm-project_NAME@_LINKER_FLAGS "@opm-project_LINKER_FLAGS@")
|
||||
set (@opm-project_NAME@_CONFIG_VARS "@opm-project_CONFIG_VARS@")
|
||||
|
||||
# libraries come from the build tree where this file was generated
|
||||
set (@opm-project_NAME@_LIBRARY "@opm-project_LIBRARY@")
|
||||
set (@opm-project_NAME@_LIBRARIES ${@opm-project_NAME@_LIBRARY} "@opm-project_LIBRARIES@")
|
||||
mark_as_advanced (@opm-project_NAME@_LIBRARY)
|
||||
|
||||
# not all projects have targets; conditionally add this part
|
||||
if (NOT "@opm-project_TARGET@" STREQUAL "")
|
||||
# add the library as a target, so that other things in the project including
|
||||
# this file may depend on it and get rebuild if this library changes.
|
||||
add_library (@opm-project_TARGET@ UNKNOWN IMPORTED)
|
||||
set_property (TARGET @opm-project_TARGET@ PROPERTY IMPORTED_LOCATION "${@opm-project_NAME@_LIBRARY}")
|
||||
endif (NOT "@opm-project_TARGET@" STREQUAL "")
|
||||
|
||||
# ensure that we build with support for C++11 to preserve ABI
|
||||
string (REPLACE "@CXX_STD0X_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string (REPLACE "@CXX_STDLIB_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string (STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
|
||||
set (CMAKE_CXX_FLAGS "@CXX_STD0X_FLAGS@@CXX_SPACE@@CXX_STDLIB_FLAGS@ ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# same as above, but for C99
|
||||
string (REPLACE "@C_STD99_FLAGS@" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string (STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
|
||||
set (CMAKE_C_FLAG "@C_STD99_FLAGS@ ${CMAKE_C_FLAGS}")
|
||||
|
||||
# build with OpenMP if that was found
|
||||
if (NOT "@OpenMP_C_FLAGS@" STREQUAL "")
|
||||
string (REPLACE "@OpenMP_C_FLAGS@" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string (STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
|
||||
set (CMAKE_C_FLAG "@OpenMP_C_FLAGS@ ${CMAKE_C_FLAGS}")
|
||||
endif (NOT "@OpenMP_C_FLAGS@" STREQUAL "")
|
||||
if (NOT "@OpenMP_CXX_FLAGS@" STREQUAL "")
|
||||
string (REPLACE "@OpenMP_CXX_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string (STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
|
||||
set (CMAKE_C_FLAG "@OpenMP_CXX_FLAGS@ ${CMAKE_CXX_FLAGS}")
|
||||
endif (NOT "@OpenMP_CXX_FLAGS@" STREQUAL "")
|
||||
|
||||
# this is the contents of config.h as far as our probes can tell:
|
@ -1,13 +0,0 @@
|
||||
prefix=@prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
CXX=@CMAKE_CXX_COMPILER@ @CXX_STD0X_FLAGS@@CXX_SPACE@@CXX_STDLIB_FLAGS@ @OpenMP_CXX_FLAGS@
|
||||
CC=@CMAKE_C_COMPILER@ @C_STD99_FLAGS@ @OpenMP_C_FLAGS@
|
||||
DEPENDENCIES=
|
||||
|
||||
Name: @name@
|
||||
Description: @description@ @major@.@minor@
|
||||
Version: @major@.@minor@
|
||||
URL: http://opm-project.org
|
||||
Libs: @target@ @libs@
|
||||
Cflags: @includes@ @defs@
|
Loading…
Reference in New Issue
Block a user