Commit 85a704f7 authored by Cédric Lachat's avatar Cédric Lachat

First commit

parents
## Copyright 2009-2016 Inria
##
## This file is part of the PaMPA software package for parallel
## mesh partitioning and adaptation.
##
## PaMPA is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## any later version.
##
## PaMPA is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## In this respect, the user's attention is drawn to the risks associated
## with loading, using, modifying and/or developing or reproducing the
## software by the user in light of its specific status of free software,
## that may mean that it is complicated to manipulate, and that also
## therefore means that it is reserved for developers and experienced
## professionals having in-depth computer knowledge. Users are therefore
## encouraged to load and test the software's suitability as regards
## their requirements in conditions enabling the security of their
## systems and/or data to be ensured and, more generally, to use and
## operate it in the same conditions as regards security.
##
## The fact that you are presently reading this means that you have had
## knowledge of the GPLv3 license and that you accept its terms.
##
#############################################################
##
## \file CMakeLists.txt
##
## \authors Cedric Lachat
##
## \brief This file is main configuration file
## to build PaMPA with CMake
##
## \date Version 1.0: from: 31 May 2011
## to: 4 Oct 2016
##
#############################################################
########################
# Main configuration #
########################
if (DEFINED ENV{JENKINS})
set(CMAKE_BUILD_TYPE $ENV{BUILD} CACHE STRING "toto" FORCE)
endif ()
cmake_minimum_required(VERSION 2.6.4)
if (NOT DEFINED FORTRAN_INTERFACE)
endif ()
if (FORTRAN_INTERFACE)
endif ()
if ((NOT DEFINED FORTRAN_INTERFACE) OR (FORTRAN_INTERFACE))
project(PAMPA C Fortran CXX)
else ()
project(PAMPA C)
#project(PAMPA C CXX) # XXX XXX à remettre
endif ()
# Add CTest
enable_testing()
# Add modules
include(CMakeDependentOption)
include(CheckSymbolExists)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeScripts)
set(CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/MOD)
# Define some variables which will be fill in with ccmake or cmake-gui
set(VALGRIND_EXE "/usr/bin/valgrind" CACHE TYPE "Valgrind with its path")
set(VALGRIND_ARGS "" CACHE TYPE "Valgrind arguments")
mark_as_advanced(VALGRIND_EXE VALGRIND_ARGS)
option(FORTRAN_INTERFACE "Build fortran interface to use PaMPA in fortran programs" OFF)
if (FORTRAN_INTERFACE)
add_definitions (-DNOT_DOXYGEN)
endif ()
set (PTHREAD_LIST "None;IO;Comm;All")
set (PTHREAD "All" CACHE STRING "Pthread use level: possible values ${PTHREAD_LIST}")
set_property (CACHE PTHREAD PROPERTY STRINGS ${PTHREAD_LIST})
list (FIND PTHREAD_LIST ${PTHREAD} FND)
if (${FND} EQUAL -1)
message (FATAL_ERROR "Value for PTHREAD is not correct, you have to choose one item in the following list ${PTHREAD_LIST}")
endif ()
set (COMM_TYPE_LIST "Automatic;Point-to-point;Collective")
set (COMM_TYPE "Point-to-point" CACHE STRING "Communication type chosen to exhange data between subdomains: possible values ${COMM_TYPE_LIST}")
set_property (CACHE COMM_TYPE PROPERTY STRINGS ${COMM_TYPE_LIST})
list (FIND COMM_TYPE_LIST ${COMM_TYPE} FND)
if (${FND} EQUAL -1)
message (FATAL_ERROR "Value for COMM_TYPE is not correct, you have to choose one item in the following list ${COMM_TYPE_LIST}")
endif ()
if (COMM_TYPE STREQUAL "Point-to-point")
add_definitions (-DPAMPA_COMM_PTOP)
elseif (COMM_TYPE STREQUAL "Collective")
add_definitions (-DPAMPA_COMM_COLL)
endif ()
set (INT_SIZE_LIST "Default;32bits;64bits;long")
set (INT_SIZE "Default" CACHE STRING "Integer size for PAMPA_Num and PAMPAF_Num, you have to choose one item between ${INT_SIZE_LIST}")
set_property (CACHE INT_SIZE PROPERTY STRINGS ${INT_SIZE_LIST})
list (FIND INT_SIZE_LIST ${INT_SIZE} FND)
if (${FND} EQUAL -1)
message (FATAL_ERROR "Value for INT_SIZE is not correct, you have to choose one item in the following list ${INT_SIZE_LIST}")
endif ()
if (INT_SIZE STREQUAL "32bits")
add_definitions (-DINTSIZE32)
elseif (INT_SIZE STREQUAL "64bits")
add_definitions (-DINTSIZE64)
elseif (INT_SIZE STREQUAL "long")
add_definitions (-DLONG)
endif ()
option(PAMPA_ADAPT "Adapt functions" ON)
if (PAMPA_ADAPT)
add_definitions (-DPAMPA_ADAPT)
endif ()
option(PAMPA_MULTILEVEL "Multilevel meshes" OFF)
option(PAMPA_RENAME "Rename internal function names" ON)
if (PAMPA_RENAME)
add_definitions (-DPAMPA_RENAME)
endif ()
option(COMMON_MEMORY_TRACE "In-house memory usage tracing" OFF)
if (COMMON_MEMORY_TRACE)
add_definitions (-DCOMMON_MEMORY_TRACE)
endif ()
cmake_dependent_option(COMMON_MEMORY_USER_FILE "User file (defined as char PAMPA_memFilename[]) for memory logs" OFF "COMMON_MEMORY_TRACE" OFF)
if (COMMON_MEMORY_USER_FILE)
add_definitions (-DCOMMON_MEMORY_USER_FILE)
endif ()
option(SAMPLES "Build samples" ON)
if (SAMPLES)
set (SAMPLE_TYPE_LIST "All;Compounds;Units")
set (SAMPLE_TYPE "All" CACHE STRING "Choose which categories of samples: possible values ${SAMPLE_TYPE_LIST}")
set_property (CACHE SAMPLE_TYPE PROPERTY STRINGS ${SAMPLE_TYPE_LIST})
list (FIND SAMPLE_TYPE_LIST ${SAMPLE_TYPE} FND)
if (${FND} EQUAL -1)
message (FATAL_ERROR "Value for SAMPLE_TYPE is not correct, you have to choose one item in the following list ${SAMPLE_TYPE_LIST}")
endif ()
set (SAMPLE_PREFIX "pampa")
endif ()
if (EXISTS ${PAMPA_SOURCE_DIR}/doc/CMakeLists.txt)
option(PAMPA_BUILD_DOC "Build documentation for PaMPA" OFF)
mark_as_advanced(PAMPA_BUILD_DOC)
endif()
option(PAMPA_BUILD_ALONE "Build PaMPA in one build folder" OFF)
mark_as_advanced(PAMPA_BUILD_ALONE)
#######################
# Find some libraries #
#######################
if (COMMON_COMPRESSION)
# BZIP2
find_package (BZip2)
if (BZIP2_FOUND)
add_definitions (-DCOMMON_FILE_COMPRESS_BZ2)
include_directories(${BZIP2_INCLUDE_DIR})
list (APPEND PAMPA_DEPENDENCIES ${BZIP2_LIBRARY} ${BZIP2_LIBRARIES})
endif (BZIP2_FOUND)
## LZMA
#find_package (LibLZMA)
#if (LibLZMA_FOUND)
# add_definitions (-DCOMMON_FILE_COMPRESS_LZMA)
# include_directories(${LibLZMA_INCLUDE_DIR})
# list (APPEND PAMPA_DEPENDENCIES ${LibLZMA_LibRARIES})
#endif (LibLZMA_FOUND)
# ZLIB
find_package (ZLIB)
if (ZLIB_FOUND)
add_definitions (-DCOMMON_FILE_COMPRESS_GZ)
include_directories(${ZLIB_INCLUDE_DIR})
list (APPEND PAMPA_DEPENDENCIES ${ZLIB_LIBRARIES})
endif (ZLIB_FOUND)
endif (COMMON_COMPRESSION)
# PT-Scotch
option (PTSCOTCH "Build PaMPA with PT-Scotch dependencies" ON)
if (PTSCOTCH)
add_definitions (-DPTSCOTCH)
set(PTSCOTCH_HOME "" CACHE PATH "PT-Scotch home directory")
find_package(PTSCOTCH REQUIRED)
file(STRINGS "${PTSCOTCH_INCLUDE_DIR}/scotch.h" CHECK_SCOTCH_VERSION REGEX "^[ \t]*#define[ \t]+SCOTCH_[A-Z]+[ \t]+[0-9]+.*$")
foreach(item IN ITEMS VERSION RELEASE PATCHLEVEL)
string(REGEX REPLACE ".*#define[ \t]+SCOTCH_${item}[ \t]+([0-9]+).*" "\\1" XYZ ${CHECK_SCOTCH_VERSION})
set (SCOTCH_${item} ${XYZ})
endforeach()
# XXX uncomment this test when Scotch 6.0.4 will be available
#if (${SCOTCH_VERSION}.${SCOTCH_RELEASE}.${SCOTCH_PATCHLEVEL} VERSION_LESS 6.0.4)
# message (FATAL_ERROR "PT-Scotch version must be greater than or equal to 6.0.4")
#endif ()
include_directories(${PTSCOTCH_INCLUDE_DIR})
else ()
unset (PTSCOTCH_HOME CACHE)
endif ()
# MPI
set(MPI_COMPILER mpicc)
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
if (MPI_C_LIBRARIES)
list (APPEND PAMPA_DEPENDENCIES ${MPI_C_LIBRARIES} m)
else ()
list (APPEND PAMPA_DEPENDENCIES ${MPI_LIBRARIES} m)
endif ()
if (PAMPA_BUILD_ALONE)
include_directories(${PAMPA_SOURCE_DIR}/include)
endif ()
# Pthread
if (NOT PTHREAD STREQUAL "None")
find_package(Threads REQUIRED)
if (NOT CMAKE_USE_PTHREADS_INIT) # if pthread was not found
message (FATAL_ERROR "Pthread are not available")
endif()
if (PTHREAD STREQUAL "IO" OR PTHREAD STREQUAL "All")
add_definitions(-DCOMMON_PTHREAD)
endif ()
if (PTHREAD STREQUAL "Comm" OR PTHREAD STREQUAL "All")
add_definitions(-DPAMPA_PTHREAD)
endif ()
list (APPEND PAMPA_DEPENDENCIES ${CMAKE_THREAD_LIBS_INIT})
endif ()
# Define PaMPA version
set(PAMPA_CORE_VERSION "2")
set(PAMPA_CORE_RELEASE "0")
set(PAMPA_CORE_PATCHLEVEL "0")
# Add some flags
add_definitions(-Drestrict=__restrict)
# Check CMake version
if (${CMAKE_VERSION} VERSION_LESS 2.8.4)
set (OLD_CMAKE 1)
endif ()
set (LIBRARY_OUTPUT_DIRECTORY ${PAMPA_SOURCE_DIR}/pampa_lib)
# SCM Version Option
option (SCM_VERSIONS "Get SCM Versions for softwares" OFF)
if (SCM_VERSIONS)
add_definitions(-DSCM_VERSIONS)
if (PTSCOTCH)
set(SCM_PTSCOTCH_HOME "" CACHE PATH "SCM PT-Scotch path")
list(APPEND VERSIONS_EXT_ARGS
PTSCOTCH:${SCM_PTSCOTCH_HOME}:${PTSCOTCH_LIBRARY},${SCOTCH_LIBRARY},${PTSCOTCH_EXTRA_LIBRARY})
list(APPEND VERSIONS_EXT_DEPS
${PTSCOTCH_LIBRARY} ${SCOTCH_LIBRARY} ${PTSCOTCH_EXTRA_LIBRARY})
endif ()
endif ()
option(COMMON_COMPRESSION "Build with founded compression libraries (CMake will search automatically which are availables" ON)
########################
# tests #
########################
if (CMAKE_VERSION VERSION_GREATER "2.8.11")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test2.c "
#include <stdio.h>
#include <stdlib.h>
#ifdef EXT
extern
#endif
inline void f() {
}
")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test.c "
#include <stdio.h>
#include <stdlib.h>
int main() {
f();
return 0;
}
")
try_compile(TEST_INLINE ${CMAKE_CURRENT_BINARY_DIR}/test
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test.c ${CMAKE_CURRENT_BINARY_DIR}/test2.c
)
if (NOT TEST_INLINE)
try_compile(TEST_INLINE ${CMAKE_CURRENT_BINARY_DIR}/test2
SOURCES ${CMAKE_CURRENT_BINARY_DIR}/test.c ${CMAKE_CURRENT_BINARY_DIR}/test2.c
COMPILE_DEFINITIONS -DEXT
)
if (NOT TEST_INLINE)
message (FATAL_ERROR "internal error")
else ()
add_definitions (-DPAMPA_WORD_EXTERN)
endif ()
endif ()
else (CMAKE_VERSION VERSION_GREATER "2.8.11")
if (CMAKE_C_COMPILER MATCHES "gcc") # XXX Is-it just for gcc?
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test.c "
#include <stdio.h>
#include <stdlib.h>
extern
inline void f() {
}
int main() {
f();
return 0;
}
")
try_compile(TEST_INLINE ${CMAKE_CURRENT_BINARY_DIR}/test
${CMAKE_CURRENT_BINARY_DIR}/test.c
)
if (TEST_INLINE)
add_definitions (-DPAMPA_WORD_EXTERN)
endif ()
endif (CMAKE_C_COMPILER MATCHES "gcc")
endif (CMAKE_VERSION VERSION_GREATER "2.8.11")
########################
# libpampa #
########################
add_subdirectory(${PAMPA_SOURCE_DIR}/src/libpampa)
# Add dependency on PT-Scotch
if (PTSCOTCH)
list (APPEND PAMPA_DEPENDENCIES ${PTSCOTCH_LIBRARY})
list (APPEND PAMPA_DEPENDENCIES ${SCOTCH_LIBRARY})
list (APPEND PAMPA_DEPENDENCIES ${PTSCOTCH_EXTRA_LIBRARY})
endif ()
########################
# samples #
########################
if (SAMPLES)
add_subdirectory(${PAMPA_SOURCE_DIR}/src/samples)
endif ()
########################
# tests #
########################
# Add target on Unix
if(UNIX)
add_custom_target(all_and_test COMMAND make all COMMAND ctest --force-new-ctest-process --output-on-failure)
endif(UNIX)
########################
# real clean #
########################
if(UNIX)
if (PAMPA_BUILD_ALONE)
add_custom_target(realclean
COMMAND make clean
COMMAND ${CMAKE_COMMAND} -E remove ${PAMPA_SOURCE_DIR}/include/*
COMMAND ${CMAKE_COMMAND} -E remove ${PAMPA_SOURCE_DIR}/lib/*
)
else ()
add_custom_target(realclean
COMMAND make clean
)
endif ()
endif(UNIX)
########################
# install #
########################
########################
# uninstall #
########################
# uninstall target
configure_file(
"${PAMPA_SOURCE_DIR}/src/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
########################
# documentation #
########################