Skip to content
Snippets Groups Projects
Commit eb2e4dfc authored by Franck Pérignon's avatar Franck Pérignon
Browse files

Ajout du rep Parmes, modele vide pour proto en C++. Ajout de quelques scripts cmake

parent bd00daa9
No related branches found
No related tags found
No related merge requests found
# - Try to find Metis
# Once done, this will define
#
# Metis_FOUND - system has Metis
# Metis_INCLUDE_DIRS - the Metis include directories
# Metis_LIBRARIES - link these to use Metis
#
# Franck Perignon, jan. 2011, from http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
#
#
include(LibFindMacros)
# Use pkg-config to get hints about paths
libfind_pkg_check_modules(Metis_PKGCONF Metis)
# Include dir
find_path(
Metis_INCLUDE_DIR
NAMES metis.h
PATHS ENV INCLUDE ENV PATH ${Metis_PKGCONF_INCLUDE_DIRS}
)
# Finally the library itself
find_library(
Metis_LIBRARY
NAMES metis
PATHS ${Metis_PKGCONF_LIBRARY_DIRS} ENV LIBRARY_PATH ENV LD_LIBRARY_PATH
)
set(Metis_PROCESS_INCLUDES Metis_INCLUDE_DIR)
set(Metis_PROCESS_LIBS Metis_LIBRARY)
libfind_process(Metis)
# - Try to find ppm_core library
# Once done, this will define
#
# PPMCore_FOUND - system has ppm_core
# PPMCore_INCLUDE_DIRS - the ppm_core include directories
# PPMCore_LIBRARIES - link these to use ppm_core
#
# LJK, Franck Perignon, jan. 2011
#
#
include(LibFindMacros)
# Use pkg-config to get hints about paths
libfind_pkg_check_modules(PPMCore_PKGCONF PPMCore)
# Modules and headers location
find_path(
PPMCore_MODULES_DIR
NAMES ppm_module_alloc.mod
PATHS ENV INCLUDE ENV PATH ${PPMCore_PKGCONF_INCLUDE_DIRS} ${PPMCore}/include/Modules
)
find_path(
PPMCore_INCLUDE_DIR
NAMES ppm_error.h
PATHS ENV INCLUDE ENV PATH ${PPMCore_PKGCONF_INCLUDE_DIRS} ${PPMCore}/include/
)
# Finally the library itself
find_library(
PPMCore_LIBRARY
NAMES ppm_core
PATHS ${PPMCore_PKGCONF_LIBRARY_DIRS} ENV LIBRARY_PATH ENV LD_LIBRARY_PATH ${PPMCore}/lib
)
if(PPMCore_INCLUDE_DIR AND PPMCore_MODULES_DIR)
set(PPMCore_INCLUDE_DIR ${PPMCore_INCLUDE_DIR} ${PPMCore_MODULES_DIR})
endif(PPMCore_INCLUDE_DIR AND PPMCore_MODULES_DIR)
set(PPMCore_PROCESS_INCLUDES PPMCore_INCLUDE_DIR)
set(PPMCore_PROCESS_LIBS PPMCore_LIBRARY)
libfind_process(PPMCore)
# - Try to find ppmnumerics library
# Once done, this will define
#
# PPMNumerics_FOUND - system has ppm_numerics
# PPMNumerics_INCLUDE_DIRS - the ppm_numerics include directories
# PPMNumerics_LIBRARIES - link these to use ppm_numerics
#
# LJK, Franck Perignon, jan. 2011
#
#
include(LibFindMacros)
# Dependencies
libfind_package(PPMNumerics PPMCore)
# Use pkg-config to get hints about paths
libfind_pkg_check_modules(PPMNumerics_PKGCONF PPMNumerics)
# Modules and headers location
find_path(
PPMNumerics_MODULES_DIR
NAMES ppm_module_alloc.mod
PATHS ENV INCLUDE ENV PATH ${PPMNumerics_PKGCONF_INCLUDE_DIRS}
)
find_path(
PPMNumerics_INCLUDE_DIR
NAMES ppm_error.h
PATHS ENV INCLUDE ENV PATH ${PPMNumerics_PKGCONF_INCLUDE_DIRS}
)
# Finally the library itself
find_library(
PPMNumerics_LIBRARY
NAMES ppmcore
PATHS ${PPMNumerics_PKGCONF_LIBRARY_DIRS} ENV LIBRARY_PATH ENV LD_LIBRARY_PATH
)
if(PPMNumerics_INCLUDE_DIR AND PPMNumerics_MODULES_DIR)
set(PPMNumerics_INCLUDE_DIR ${PPMNumerics_INCLUDE_DIR} ${PPMNumerics_MODULES_DIR})
endif(PPMNumerics_INCLUDE_DIR AND PPMNumerics_MODULES_DIR)
set(PPMNumerics_PROCESS_INCLUDES PPMNumerics_INCLUDE_DIR)
set(PPMNumerics_PROCESS_LIBS PPMNumerics_LIBRARY)
libfind_process(PPMNumerics)
# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments
# used for the current package. For this to work, the first parameter must be the
# prefix of the current package, then the prefix of the new package etc, which are
# passed to find_package.
macro (libfind_package PREFIX)
set (LIBFIND_PACKAGE_ARGS ${ARGN})
if (${PREFIX}_FIND_QUIETLY)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET)
endif (${PREFIX}_FIND_QUIETLY)
if (${PREFIX}_FIND_REQUIRED)
set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED)
endif (${PREFIX}_FIND_REQUIRED)
find_package(${LIBFIND_PACKAGE_ARGS})
endmacro (libfind_package)
# CMake developers made the UsePkgConfig system deprecated in the same release (2.6)
# where they added pkg_check_modules. Consequently I need to support both in my scripts
# to avoid those deprecated warnings. Here's a helper that does just that.
# Works identically to pkg_check_modules, except that no checks are needed prior to use.
macro (libfind_pkg_check_modules PREFIX PKGNAME)
if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
include(UsePkgConfig)
pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS)
else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(${PREFIX} ${PKGNAME})
endif (PKG_CONFIG_FOUND)
endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4)
endmacro (libfind_pkg_check_modules)
# Do the final processing once the paths have been detected.
# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
# all the variables, each of which contain one include directory.
# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
# Also handles errors in case library detection was required, etc.
macro (libfind_process PREFIX)
# Skip processing if already processed during this run
if (NOT ${PREFIX}_FOUND)
# Start with the assumption that the library was found
set (${PREFIX}_FOUND TRUE)
# Process all includes and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_INCLUDES})
if (${i})
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)
# Process all libraries and set _FOUND to false if any are missing
foreach (i ${${PREFIX}_PROCESS_LIBS})
if (${i})
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}})
mark_as_advanced(${i})
else (${i})
set (${PREFIX}_FOUND FALSE)
endif (${i})
endforeach (i)
# Print message and/or exit on fatal error
if (${PREFIX}_FOUND)
if (NOT ${PREFIX}_FIND_QUIETLY)
message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
endif (NOT ${PREFIX}_FIND_QUIETLY)
else (${PREFIX}_FOUND)
if (${PREFIX}_FIND_REQUIRED)
foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS})
message("${i}=${${i}}")
endforeach (i)
message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.")
endif (${PREFIX}_FIND_REQUIRED)
endif (${PREFIX}_FOUND)
endif (NOT ${PREFIX}_FOUND)
endmacro (libfind_process)
macro(libfind_library PREFIX basename)
set(TMP "")
if(MSVC80)
set(TMP -vc80)
endif(MSVC80)
if(MSVC90)
set(TMP -vc90)
endif(MSVC90)
set(${PREFIX}_LIBNAMES ${basename}${TMP})
if(${ARGC} GREATER 2)
set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2})
string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES})
set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP})
endif(${ARGC} GREATER 2)
find_library(${PREFIX}_LIBRARY
NAMES ${${PREFIX}_LIBNAMES}
PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}
)
endmacro(libfind_library)
#
# Use this to force out-of source build.
#
option(IN_SOURCE_BUILD "Switch to on if you really want a build in the source directory." OFF)
if(NOT IN_SOURCE_BUILD)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "CMake generation for this library is not allowed within the source directory!
Remove the CMakeCache.txt file and try again from another folder, e.g.:
rm CMakeCache.txt
cd <somewhere (preferably a local place on your computer and not a network folder)>
cmake <source directory>
If you really need an in source build, then run : cmake -DIN_SOURCE_BUILD=ON
")
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
endif(NOT IN_SOURCE_BUILD)
include(LibFindMacros)
# Basic list manipulation
macro(CAR var)
set(${var} ${ARGV1})
endmacro(CAR)
macro(CDR var junk)
set(${var} ${ARGN})
endmacro(CDR)
# LIST(APPEND ...) is not correct on <COMPILER>_FLAGS
macro(APPEND_FLAGS)
CAR(_V ${ARGV})
CDR(_F ${ARGV})
set(${_V} "${${_V}} ${_F}")
endmacro(APPEND_FLAGS)
# Add all dirs in _DIRS into the searched directories for include files
# Set, for dir in _DIRS:
# - ${PROJECT_NAME}_INCLUDE_DIRECTORIES
# - ${PROJECT_NAME}_REMEMBER_INC_${dir} (to avoid multiple sets)
macro(REMEMBER_INCLUDE_DIRECTORIES _DIRS)
foreach(_D ${_DIRS})
if(NOT ${PROJECT_NAME}_REMEMBER_INC_${_D})
set(${PROJECT_NAME}_REMEMBER_INC_${_D} TRUE)
list(APPEND ${PROJECT_NAME}_INCLUDE_DIRECTORIES ${_D})
include_directories(${_DIRS})
endif(NOT ${PROJECT_NAME}_REMEMBER_INC_${_D})
endforeach(_D ${_DIRS})
endmacro(REMEMBER_INCLUDE_DIRECTORIES _DIRS)
# Add all dirs in _DIRS into the searched directories for linked libraries
# Set, for dir in _DIRS:
# - ${PROJECT_NAME}_LINK_DIRECTORIES
# - ${PROJECT_NAME}_REMEMBER_LINK_${dir} (to avoid multiple sets)
macro(REMEMBER_LINK_DIRECTORIES _DIRS)
foreach(_D ${_DIRS})
if(NOT ${PROJECT_NAME}_REMEMBER_LINK_${_D})
set(${PROJECT_NAME}_REMEMBER_LINK_${_D} TRUE)
list(APPEND ${PROJECT_NAME}_LINK_DIRECTORIES ${_D})
link_directories(${_D})
endif(NOT ${PROJECT_NAME}_REMEMBER_LINK_${_D})
endforeach(_D ${_DIRS})
endmacro(REMEMBER_LINK_DIRECTORIES _DIRS)
# Add all libraries in _LIBS into the searched directories for linked libraries
# Set, for lib in _LIBS:
# - ${PROJECT_NAME}_LINK_LIBRARIES
# - ${PROJECT_NAME}_REMEMBER_LINK_LIBRARIES_${lib} (to avoid multiple sets)
macro(REMEMBER_LINK_LIBRARIES _LIBS)
foreach(_LIB ${_LIBS})
if(NOT ${PROJECT_NAME}_REMEMBER_LINK_LIBRARIES_${_LIB})
set(${PROJECT_NAME}_REMEMBER_LINK_LIBRARIES_${_LIB} TRUE)
list(APPEND ${PROJECT_NAME}_LINK_LIBRARIES ${_LIB})
endif(NOT ${PROJECT_NAME}_REMEMBER_LINK_LIBRARIES_${_LIB})
endforeach(_LIB ${_LIBS})
endmacro(REMEMBER_LINK_LIBRARIES _LIBS)
# The use of ADD_DEFINITION results in a warning with Fortran compiler
macro(APPEND_C_FLAGS)
APPEND_FLAGS(CMAKE_C_FLAGS ${ARGV})
endmacro(APPEND_C_FLAGS)
macro(APPEND_CXX_FLAGS)
APPEND_FLAGS(CMAKE_CXX_FLAGS ${ARGV})
endmacro(APPEND_CXX_FLAGS)
macro(APPEND_Fortran_FLAGS)
APPEND_FLAGS(CMAKE_Fortran_FLAGS ${ARGV})
endmacro(APPEND_Fortran_FLAGS)
# debug
macro(display V)
MESSAGE(STATUS "${V} = ${${V}}")
endmacro(display V)
../CMake
\ No newline at end of file
#=======================================================
# cmake utility to compile and install split2d library
#
# F. Pérignon, 17 fev 2011
#
#=======================================================
# ============= Global Settings =============
# Set minimum version
cmake_minimum_required(VERSION 2.8)
# Set policy
cmake_policy(VERSION 2.8)
# Set cmake modules directory (i.e. the one which contains all user-defined FindXXX.cmake files among other things)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
# Force out-of-source build
include(OutOfSourceBuild)
# Some usefull macros
include(Tools)
# User defined options
option(VERBOSE_MODE "enable verbose mode for cmake exec" ON)
# ============= The project =============
# Set project name and project languages
# => this automatically defines:
# - ${PROJECT_NAME}_BINARY_DIR : where you have run cmake, i.e. the place for compilation
# - ${PROJECT_NAME}_SOURCE_DIR : where sources (.f and .h and this CMakeLists.txt) are located
# Note that because of OutOfSourceBuild, binary_dir and source_dir must be different.
set(PROJECT_NAME split2D)
project(${PROJECT_NAME} Fortran)
# ============= Prepare compilation =============
# Force a default build type if not provided by user
# CMAKE_BUILD_TYPE = empty, Debug, Release, RelWithDebInfo or MinSizeRel.
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING "Choose the type of build, options are: None, Debug, Release, RelWithDebInfo or MinSizeRel." FORCE)
display(CMAKE_BUILD_TYPE)
endif (NOT CMAKE_BUILD_TYPE)
# If the project uses Fortran ...
# Set module files directory (i.e. where .mod will be created)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/Modules)
# To add compilation flags:
append_Fortran_FLAGS("-Wall")
# --------------------------------------------
# Create executable or lib
# --------------------------------------------
# Source files list:
file(GLOB ${PROJECT_NAME}_SRC src/*.f90 src/*.h)
# Creates the executable
add_executable(${PROJECT_NAME} ${${PROJECT_NAME}_SRC})
# --------------------------------------------
# RPATH
# --------------------------------------------
# do not skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# the RPATH to be used when installing
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# ============= Prepare install =============
# The library
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin)
# The headers and/or the modules
install(DIRECTORY ${CMAKE_BINARY_DIR}/Modules DESTINATION include)
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment