2013-12-09 08:19:06 -06:00
|
|
|
cmake_minimum_required( VERSION 2.8 )
|
2013-01-17 06:33:59 -06:00
|
|
|
project( ERT C CXX )
|
2013-01-31 08:39:40 -06:00
|
|
|
|
2014-10-09 13:13:04 -05:00
|
|
|
if(POLICY CMP0042)
|
|
|
|
cmake_policy(SET CMP0042 OLD)
|
|
|
|
endif()
|
|
|
|
|
2015-07-01 06:24:34 -05:00
|
|
|
#-----------------------------------------------------------------
|
|
|
|
|
2016-10-13 06:31:31 -05:00
|
|
|
set( ERT_VERSION_MAJOR 2 ) # Remember to update release notes whenever
|
2017-04-24 14:53:45 -05:00
|
|
|
set( ERT_VERSION_MINOR 2 ) # you change the ERT_VERSION_MINOR or MAJOR
|
2016-10-13 06:31:31 -05:00
|
|
|
set( ERT_VERSION_MICRO git ) # with "new in Ert Version X.X.X"!
|
2015-07-01 06:24:34 -05:00
|
|
|
|
|
|
|
# If the micro version is not integer, that should be interpreted as a
|
|
|
|
# development version leading towards version MAJOR.MINOR.0
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------
|
2014-10-09 13:13:04 -05:00
|
|
|
|
2016-10-13 06:31:31 -05:00
|
|
|
option( BUILD_TESTS "Should the tests be built" OFF)
|
|
|
|
option( BUILD_APPLICATIONS "Should we build small utility applications" OFF)
|
|
|
|
option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF)
|
|
|
|
option( BUILD_PYTHON "Run py_compile on the python wrappers" ON )
|
|
|
|
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
|
|
|
|
option( INSTALL_ERT "Should anything be installed when issuing make install?" ON )
|
2017-02-07 06:44:59 -06:00
|
|
|
option( ERT_USE_OPENMP "Use OpenMP" OFF )
|
2016-10-13 06:31:31 -05:00
|
|
|
option( ERT_DOC "Build ERT documantation" OFF)
|
|
|
|
option( ERT_BUILD_CXX "Build some CXX wrappers" ON)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set(STATOIL_TESTDATA_ROOT "" CACHE PATH "Root to Statoil internal testdata")
|
|
|
|
if (EXISTS ${STATOIL_TESTDATA_ROOT})
|
|
|
|
set( LINK "${CMAKE_CURRENT_SOURCE_DIR}/test-data/Statoil" )
|
|
|
|
if (EXISTS ${LINK})
|
|
|
|
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove "${LINK}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${STATOIL_TESTDATA_ROOT}" "${LINK}")
|
|
|
|
message(STATUS "Linking testdata: ${LINK} -> ${STATOIL_TESTDATA_ROOT}")
|
|
|
|
endif()
|
|
|
|
|
2013-01-31 08:39:40 -06:00
|
|
|
|
|
|
|
|
2013-01-17 06:33:59 -06:00
|
|
|
include( CheckFunctionExists )
|
2013-10-07 06:31:13 -05:00
|
|
|
include( CheckTypeSize )
|
2013-01-18 01:53:37 -06:00
|
|
|
ENABLE_TESTING()
|
2013-01-17 06:33:59 -06:00
|
|
|
|
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
2017-02-07 06:44:59 -06:00
|
|
|
message(STATUS "Found Linux")
|
2013-01-17 06:33:59 -06:00
|
|
|
set(ERT_LINUX TRUE )
|
|
|
|
add_definitions( -DERT_LINUX )
|
2016-04-19 07:48:14 -05:00
|
|
|
set( ERT_BINARY_POSTFIX .${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} )
|
2014-10-09 13:13:04 -05:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2017-02-07 06:44:59 -06:00
|
|
|
message(STATUS "Found Darwin")
|
2014-10-09 13:13:04 -05:00
|
|
|
set(ERT_LINUX TRUE )
|
|
|
|
set(ERT_MAC TRUE)
|
|
|
|
add_definitions( -DERT_LINUX )
|
2016-04-19 07:48:14 -05:00
|
|
|
set( ERT_BINARY_POSTFIX .${ERT_VERSION_MAJOR}.${ERT_VERSION_MINOR} )
|
2013-01-17 06:33:59 -06:00
|
|
|
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
2017-02-07 06:44:59 -06:00
|
|
|
message(STATUS "Found Windows")
|
2013-01-17 06:33:59 -06:00
|
|
|
set(ERT_WINDOWS TRUE)
|
|
|
|
add_definitions( -DERT_WINDOWS )
|
2017-02-07 06:44:59 -06:00
|
|
|
endif()
|
2013-05-10 03:25:46 -05:00
|
|
|
|
2014-10-09 13:13:04 -05:00
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
|
|
|
|
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
|
|
|
|
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
|
|
|
# Set the possible values of build type for cmake-gui
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
|
|
|
|
"MinSizeRel" "RelWithDebInfo")
|
|
|
|
endif()
|
2013-10-07 06:31:13 -05:00
|
|
|
|
2013-08-26 07:44:03 -05:00
|
|
|
# Treat warnings as errors if not on Windows
|
2014-10-09 13:13:04 -05:00
|
|
|
if (NOT ERT_WINDOWS)
|
2017-02-07 06:44:59 -06:00
|
|
|
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Wall -Wno-unknown-pragmas ")
|
2016-10-13 06:31:31 -05:00
|
|
|
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall " )
|
2014-10-09 13:13:04 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
|
2013-04-29 06:21:36 -05:00
|
|
|
endif()
|
2013-01-17 06:33:59 -06:00
|
|
|
|
2014-10-09 13:13:04 -05:00
|
|
|
|
2013-10-07 06:31:13 -05:00
|
|
|
if (ERT_USE_OPENMP)
|
2017-02-07 06:44:59 -06:00
|
|
|
find_package(OpenMP)
|
|
|
|
if (OPENMP_FOUND)
|
|
|
|
message(STATUS "Enabling OpenMP support")
|
|
|
|
# The actual use of OpenMP is only in the libecl library - the compile flags is only applied there.
|
|
|
|
else()
|
|
|
|
set( ERT_USE_OPENMP OFF )
|
|
|
|
message(STATUS "OpenMP package not found - OpenMP disabled")
|
|
|
|
endif()
|
2013-10-07 06:31:13 -05:00
|
|
|
endif()
|
|
|
|
|
2017-02-07 06:44:59 -06:00
|
|
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
|
|
|
find_package(CXX11Features)
|
|
|
|
|
|
|
|
|
2013-10-07 06:31:13 -05:00
|
|
|
|
2016-04-19 07:48:14 -05:00
|
|
|
#-----------------------------------------------------------------
|
2013-08-26 07:44:03 -05:00
|
|
|
|
2016-04-19 07:48:14 -05:00
|
|
|
# Checking based on compiling. Some of the code generates warnings, so we just cut down to bare-bone compiler flags.
|
2013-01-17 06:33:59 -06:00
|
|
|
|
2016-04-19 07:48:14 -05:00
|
|
|
set( CMAKE_C_FLAGS_main ${CMAKE_C_FLAGS} )
|
|
|
|
set( CMAKE_CXX_FLAGS_main ${CMAKE_CXX_FLAGS} )
|
2015-07-01 06:24:34 -05:00
|
|
|
|
2016-04-19 07:48:14 -05:00
|
|
|
if (NOT ERT_WINDOWS)
|
2016-10-13 06:31:31 -05:00
|
|
|
set( CMAKE_C_FLAGS_main "${CMAKE_C_FLAGS} -std=gnu99" )
|
2015-07-01 06:24:34 -05:00
|
|
|
endif()
|
|
|
|
|
2016-04-19 07:48:14 -05:00
|
|
|
set( ERT_EXTERNAL_UTIL_LIBS "" )
|
|
|
|
include(cmake/ert_build_check.cmake)
|
|
|
|
include(cmake/ert_api_check.cmake)
|
|
|
|
include(cmake/ert_lib_check.cmake)
|
|
|
|
|
|
|
|
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS_main} )
|
|
|
|
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_main} )
|
|
|
|
|
|
|
|
include(cmake/Modules/UseMultiArch.cmake)
|
|
|
|
include(cmake/ert_link.cmake)
|
|
|
|
|
2015-07-01 06:24:34 -05:00
|
|
|
#-----------------------------------------------------------------
|
|
|
|
|
2013-10-07 06:31:13 -05:00
|
|
|
set(INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group")
|
2013-01-31 08:39:40 -06:00
|
|
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
|
|
|
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
|
|
|
|
2013-10-07 06:31:13 -05:00
|
|
|
|
2013-01-17 06:33:59 -06:00
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
add_definitions( -D__func__="\\"????\\"")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ERT_LINUX)
|
|
|
|
set( NEED_LIBM TRUE )
|
|
|
|
set( LINK_STATIC FALSE )
|
2013-04-29 06:13:42 -05:00
|
|
|
add_definitions( -DHAVE_PROC )
|
2013-01-17 06:33:59 -06:00
|
|
|
else()
|
|
|
|
set( NEED_LIBM FALSE )
|
|
|
|
set( LINK_STATIC TRUE )
|
|
|
|
endif()
|
|
|
|
|
2013-01-31 08:39:40 -06:00
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libert_util/include )
|
|
|
|
include_directories( ${PROJECT_BINARY_DIR}/libert_util/include )
|
|
|
|
if (MSVC)
|
|
|
|
include_directories( ${PROJECT_BINARY_DIR}/libert_util/include/ert/util )
|
|
|
|
endif()
|
|
|
|
add_subdirectory( libert_util )
|
2013-01-17 06:33:59 -06:00
|
|
|
|
|
|
|
|
2013-01-31 08:39:40 -06:00
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libgeometry/include )
|
2013-01-17 06:33:59 -06:00
|
|
|
add_subdirectory( libgeometry )
|
2013-01-31 08:39:40 -06:00
|
|
|
|
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libecl/include )
|
2013-01-17 06:33:59 -06:00
|
|
|
add_subdirectory( libecl )
|
|
|
|
|
2015-07-01 06:24:34 -05:00
|
|
|
if (ERT_BUILD_CXX)
|
2016-04-19 07:48:14 -05:00
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libert_utilxx/include )
|
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libeclxx/include )
|
|
|
|
|
|
|
|
add_subdirectory( libert_utilxx )
|
|
|
|
add_subdirectory( libeclxx )
|
2015-07-01 06:24:34 -05:00
|
|
|
endif()
|
|
|
|
|
2013-01-31 08:39:40 -06:00
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libecl_well/include )
|
|
|
|
add_subdirectory( libecl_well )
|
|
|
|
|
|
|
|
if (BUILD_PYTHON)
|
2015-10-30 03:43:10 -05:00
|
|
|
if (ERT_WINDOWS)
|
2017-05-08 06:37:39 -05:00
|
|
|
message(WARNING "Python is not supported on Windows")
|
|
|
|
set( BUILD_PYTHON OFF )
|
2015-10-30 03:43:10 -05:00
|
|
|
else()
|
2017-05-08 06:37:39 -05:00
|
|
|
# If finding the Python interpreter and required packages
|
|
|
|
# fails in the python/CMakeLists.txt file the BUILD_PYTHON
|
|
|
|
# will be set to OFF.
|
2015-10-30 03:43:10 -05:00
|
|
|
add_subdirectory( python )
|
2017-02-07 06:44:59 -06:00
|
|
|
|
2015-10-30 03:43:10 -05:00
|
|
|
if(ERT_DOC)
|
|
|
|
add_subdirectory( docs )
|
|
|
|
endif()
|
2014-10-09 13:13:04 -05:00
|
|
|
endif()
|
2013-01-17 06:33:59 -06:00
|
|
|
endif()
|
|
|
|
|
2017-05-08 06:37:39 -05:00
|
|
|
if (BUILD_PYTHON)
|
|
|
|
if (NOT ${BUILD_SHARED_LIBS})
|
|
|
|
message(FATAL_ERROR "The Python wrappers require shared libraries")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
configure_file( cmake/libecl-config.cmake.in libecl-config.cmake @ONLY)
|
|
|
|
configure_file( cmake/libecl-config-version.cmake.in libecl-config-version.cmake @ONLY)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libecl-config.cmake
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/libecl-config-version.cmake
|
|
|
|
DESTINATION lib/libecl )
|