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-04-19 07:48:14 -05:00
|
|
|
set( ERT_VERSION_MAJOR 2 )
|
|
|
|
set( ERT_VERSION_MINOR 0 )
|
2015-07-01 06:24:34 -05:00
|
|
|
set( ERT_VERSION_MICRO git )
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2013-01-31 08:39:40 -06:00
|
|
|
|
2013-04-04 01:24:40 -05:00
|
|
|
option( BUILD_ERT "Build the full ERT application - Linux only" OFF)
|
|
|
|
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)
|
2015-10-30 03:43:10 -05:00
|
|
|
option( BUILD_PYTHON "Run py_compile on the python wrappers" ON)
|
2013-10-07 06:31:13 -05:00
|
|
|
option( BUILD_SHARED_LIBS "Build shared libraries" ON )
|
2013-04-04 01:24:40 -05:00
|
|
|
option( INSTALL_ERT "Should anything be installed when issuing make install?" ON)
|
2013-10-07 06:31:13 -05:00
|
|
|
option( ERT_BUILD_GUI "Should the pyQt based gui be compiled and installed" OFF )
|
2013-12-09 08:19:06 -06:00
|
|
|
option( ERT_USE_OPENMP "Use OpenMP - currently only in EclGrid" OFF)
|
2014-10-09 13:13:04 -05:00
|
|
|
option( ERT_DOC "Build ERT documantation" OFF)
|
2016-04-19 07:48:14 -05:00
|
|
|
option( ERT_BUILD_CXX "Build some CXX wrappers" ON)
|
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")
|
|
|
|
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")
|
|
|
|
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")
|
|
|
|
set(ERT_WINDOWS TRUE)
|
|
|
|
add_definitions( -DERT_WINDOWS )
|
2013-05-10 03:25:46 -05:00
|
|
|
endif()
|
|
|
|
|
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)
|
|
|
|
set( CMAKE_C_FLAGS "-std=gnu99 -Wall -Wno-unknown-pragmas ")
|
|
|
|
set( CMAKE_CXX_FLAGS "-Wall " )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
|
2016-04-19 07:48:14 -05:00
|
|
|
else()
|
2015-07-01 06:24:34 -05:00
|
|
|
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x" )
|
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)
|
|
|
|
find_package(OpenMP)
|
|
|
|
if (OPENMP_FOUND)
|
|
|
|
message(STATUS "Enabling OpenMP support")
|
2013-12-09 08:19:06 -06:00
|
|
|
# The actual use of OpenMP is only in the libecl library - the compile flags is only applied there.
|
2013-10-07 06:31:13 -05:00
|
|
|
else()
|
2013-12-09 08:19:06 -06:00
|
|
|
set( ERT_USE_OPENMP OFF )
|
2013-10-07 06:31:13 -05:00
|
|
|
message(STATUS "OpenMP package not found - OpenMP disabled")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
set( CMAKE_C_FLAGS "-std=gnu99" )
|
|
|
|
set( CMAKE_CXX_FLAGS "-std=c++0x")
|
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
|
|
|
|
|
|
|
if (BUILD_SHARED_LIBS)
|
|
|
|
set( LIBRARY_TYPE SHARED )
|
2013-01-17 06:33:59 -06:00
|
|
|
else()
|
2013-10-07 06:31:13 -05:00
|
|
|
set( LIBRARY_TYPE STATIC )
|
|
|
|
if (BUILD_ERT)
|
|
|
|
message(FATAL_ERROR "The full ERT application must be built with shared libraries")
|
|
|
|
endif()
|
|
|
|
if (BUILD_PYTHON)
|
|
|
|
message(FATAL_ERROR "The Python wrappers require shared libraries")
|
|
|
|
endif()
|
2013-08-26 07:44:03 -05:00
|
|
|
endif()
|
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 )
|
|
|
|
|
2013-01-18 01:53:37 -06:00
|
|
|
|
2013-01-17 06:33:59 -06:00
|
|
|
#-----------------------------------------------------------------
|
|
|
|
if (BUILD_ERT)
|
|
|
|
#-----------------------------------------------------------------
|
2015-04-14 08:47:22 -05:00
|
|
|
if (BUILD_TESTS)
|
|
|
|
option( ERT_LSF_SUBMIT_TEST "Build and run tests of LSF submit" OFF)
|
|
|
|
endif()
|
|
|
|
|
2014-10-09 13:13:04 -05:00
|
|
|
include(cmake/ert_module_name.cmake)
|
|
|
|
|
2013-01-31 08:39:40 -06:00
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libconfig/include )
|
2013-01-17 06:33:59 -06:00
|
|
|
add_subdirectory( libconfig )
|
2013-01-31 08:39:40 -06:00
|
|
|
|
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libsched/include )
|
2013-01-17 06:33:59 -06:00
|
|
|
add_subdirectory( libsched )
|
2013-01-31 08:39:40 -06:00
|
|
|
|
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/librms/include )
|
|
|
|
add_subdirectory( librms )
|
|
|
|
|
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libanalysis/include )
|
|
|
|
add_subdirectory( libanalysis )
|
|
|
|
|
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libjob_queue/include )
|
2013-01-17 06:33:59 -06:00
|
|
|
add_subdirectory( libjob_queue )
|
2013-01-31 08:39:40 -06:00
|
|
|
|
|
|
|
include_directories( ${PROJECT_SOURCE_DIR}/libenkf/include )
|
|
|
|
add_subdirectory( libenkf )
|
2013-04-29 06:13:42 -05:00
|
|
|
|
|
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/share DESTINATION ${CMAKE_INSTALL_PREFIX})
|
2013-01-31 08:39:40 -06:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
if (BUILD_PYTHON)
|
2015-10-30 03:43:10 -05:00
|
|
|
if (ERT_WINDOWS)
|
|
|
|
message(STATUS "Python is not supported on Windows")
|
|
|
|
else()
|
|
|
|
include(cmake/python.cmake2)
|
|
|
|
add_subdirectory( python )
|
|
|
|
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()
|
|
|
|
|