Commit bea3f89a authored by jclamber's avatar jclamber

fix cmake issues

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@150 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent de4659ee
# -*-cmake-*-
# ============================================================================
# Copyright Jean-Charles LAMBERT - 2008-2013
# e-mail: Jean-Charles.Lambert@oamp.fr
......@@ -73,7 +74,7 @@ endif ()
# create the library "MYutils"
add_library (MYutils SHARED ${LIBUTILS})
if(OSX)
set_target_properties(JCLutils PROPERTIES LINK_FLAGS "-undefined suppress -flat_namespace")
set_target_properties(JCLutils PROPERTIES LINK_FLAGS "-undefined suppress -flat_namespace")
endif(OSX)
# Destination path for the lib
......@@ -85,7 +86,11 @@ SET(LIBRARY_OUTPUT_PATH lib)
add_definitions(${OPT} -DNO_CUDA -DfalcON_NEMO -DfalcON_SINGLE -Wall ${DNOBOOST})
SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${WARNCPP} )
SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} ${WARNC} )
SET(CMAKE_Fortran_FLAGS ${CMAKE_Fortran_FLAGS} ${WARNF})
#SET(CMAKE_Fortran_FLAGS ${CMAKE_Fortran_FLAGS} ${WARNF} )
SET(CMAKE_Fortran_FLAGS ${CMAKE_Fortran_FLAGS} ${EXTRA_Fortran_FLAGS})
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message ("Fortran compiler: " ${Fortran_COMPILER_NAME})
message ("Fortran flags : " ${CMAKE_Fortran_FLAGS})
# remove -DNDEBUG in RElease mode to keep activated assert calls
STRING(REPLACE "-DNDEBUG" "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
......@@ -125,9 +130,9 @@ ENDFOREACH(exe_cpp ${execpp_sources})
# find all fortran source files
#
if (CMAKE_Fortran_COMPILER)
# Find all LIB's sources files
FILE(GLOB exe_sources ${PROJECT_SOURCE_DIR}/src/*.F)
FOREACH(exe_f ${exe_sources})
# Find all LIB's sources files
FILE(GLOB exe_sources ${PROJECT_SOURCE_DIR}/src/*.F)
FOREACH(exe_f ${exe_sources})
get_filename_component(exe ${exe_f} NAME_WE)
MESSAGE( STATUS "New executable ==> " ${exe})
......@@ -140,7 +145,7 @@ FOREACH(exe_f ${exe_sources})
SET_TARGET_PROPERTIES(${exe} PROPERTIES LINKER_LANGUAGE Fortran)
# add "-lstdc++"
#SET(CMAKE_Fortran_LINK_FLAGS "-L${NEMOLIB} ") #-lstdc++")
ENDFOREACH(exe_f ${exe_sources})
ENDFOREACH(exe_f ${exe_sources})
endif()
# ----------------------------------------------------------
......
# -*-cmake-*-
# check if fortran compiler is installed
if(DEFINED CMAKE_Fortran_COMPILER AND CMAKE_Fortran_COMPILER MATCHES "^$")
set(CMAKE_Fortran_COMPILER CMAKE_Fortran_COMPILER-NOTFOUND)
endif(DEFINED CMAKE_Fortran_COMPILER AND CMAKE_Fortran_COMPILER MATCHES "^$")
enable_language(Fortran OPTIONAL)
message(STATUS "CMAKE_Fortran_COMPILER_WORKS = ${CMAKE_Fortran_COMPILER_WORKS}")
# FFLAGS depend on the compiler
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
if (Fortran_COMPILER_NAME STREQUAL "gfortran")
# gfortran
set (EXTRA_Fortran_FLAGS " ${WARNF} -ffixed-line-length-none ")
endif()
\ No newline at end of file
# -*-cmake-*-
# ============================================================================
# Copyright Jean-Charles LAMBERT - 2009-2012
# Copyright Jean-Charles LAMBERT - 2009-2013
# e-mail: Jean-Charles.Lambert@oamp.fr
# address: Dynamique des galaxies
# Centre de donneeS Astrophysique de Marseille (CeSAM)
......
# -*-cmake-*-
# ============================================================================
# Copyright Jean-Charles LAMBERT - 2009-2012
# e-mail: Jean-Charles.Lambert@oamp.fr
......
# -*-cmake-*-
# ============================================================================
# Copyright Jean-Charles LAMBERT - 2012
# Copyright Jean-Charles LAMBERT - 2012-2013
# e-mail: Jean-Charles.Lambert@oamp.fr
# address: Dynamique des galaxies
# Centre de donneeS Astrophysique de Marseille (CeSAM)
......@@ -12,11 +13,16 @@
# CMake module to detect UNSIO library
# ============================================================================
SET(UNSIO_FOUND FALSE)
if (NOT UNSIO_SETUP)
set (UNSIOLIB UNSIOLIB-NOTFOUND)
set (UNSIO_SETUP 1)
typed_cache_set ( STRING "unsio setup" UNSIO_SETUP 1 )
if ( UNSIOPATH ) # user configure cmake with variable -DUNSIO_INSTALLPATH="/unsio/path"
SET(UNSIO_FOUND FALSE)
set (UNSIOLIB UNSIOLIB-NOTFOUND)
if ( UNSIOPATH ) # user configure cmake with variable -DUNSIO_INSTALLPATH="/unsio/path"
find_library(UNSIOLIB NAMES unsio PATHS ${UNSIOPATH}/lib)
MESSAGE (STATUS "UNSIOLIB = " ${UNSIOLIB})
......@@ -24,23 +30,25 @@ if ( UNSIOPATH ) # user configure cmake with variable -DUNSIO_INSTALLPATH="/unsi
MESSAGE(STATUS "Found UNSIOLIB =" ${UNSIOLIB})
SET(UNSIO_FOUND TRUE)
else ()
endif()
endif ()
endif ()
if (NOT UNSIO_FOUND) # try NEMO
if (NOT UNSIO_FOUND) # try NEMO
MESSAGE (STATUS "UNSIOLIB = " ${UNSIOLIB} " NEMO=" $ENV{NEMO})
find_library(UNSIOLIB NAMES unsio PATHS $ENV{NEMO}/lib)
MESSAGE (STATUS "UNSIOLIB = " ${UNSIOLIB})
MESSAGE (STATUS "UNSIOLIB = " ${UNSIOLIB} " NEMO=" $ENV{NEMO})
if ( NOT ${UNSIOLIB} STREQUAL UNSIOLIB-NOTFOUND)
MESSAGE(STATUS "Found UNSIOLIB in NEMO =" ${UNSIOLIB})
SET(UNSIO_FOUND TRUE)
SET(UNSIOPATH $ENV{NEMO})
MESSAGE(STATUS ">>>>>22" $ENV{NEMO})
else ()
MESSAGE(STATUS ">>>>>2")
endif()
endif()
endif()
if (NOT UNSIO_FOUND) # try $HOME/local
if (NOT UNSIO_FOUND) # try $HOME/local
find_library(UNSIOLIB NAMES unsio PATHS $ENV{HOME}/local/unsio/lib)
MESSAGE (STATUS "UNSIOLIB = " ${UNSIOLIB} " -- " $ENV{HOME})
if (NOT ${UNSIOLIB} STREQUAL UNSIOLIB-NOTFOUND)
......@@ -48,13 +56,13 @@ if (NOT UNSIO_FOUND) # try $HOME/local
SET(UNSIO_FOUND TRUE)
SET(UNSIOPATH $ENV{HOME}/local/unsio)
else ()
endif()
endif()
endif()
if (NOT UNSIO_FOUND) # ABORT
if (NOT UNSIO_FOUND) # ABORT
message(SEND_ERROR "UNSIO not found - skipping building tests")
else()
endif()
else()
typed_cache_set ( STRING "UNSIOPATH location" UNSIOPATH ${UNSIOPATH} )
endif()
endif () #NOT UNSIO_SETUP
# -*-cmake-*-
# ============================================================================
# Copyright Jean-Charles LAMBERT - 2009-2012
# Copyright Jean-Charles LAMBERT - 2009-2013
# e-mail: Jean-Charles.Lambert@oamp.fr
# address: Dynamique des galaxies
# Centre de donneeS Astrophysique de Marseille (CeSAM)
......@@ -12,72 +13,69 @@
if ( NOT SETUP_FLAGS_INCLUDED )
set( SETUP_FLAGS_INCLUDED 1 )
macro( typed_cache_set type doc var )
macro( typed_cache_set type doc var )
set ( ${var} ${ARGN} CACHE ${type} ${doc} FORCE )
set ( ${var} ${ARGN} CACHE ${type} ${doc} FORCE )
endmacro()
endmacro()
typed_cache_set ( STRING "setup flags" SETUP_FLAGS_INCLUDED 1 )
typed_cache_set ( STRING "setup flags" SETUP_FLAGS_INCLUDED 1 )
# Set a default build type if none is given
if ( NOT CMAKE_BUILD_TYPE ) # Debug default
# Set a default build type if none is given
if ( NOT CMAKE_BUILD_TYPE ) # Debug default
typed_cache_set ( STRING "Build type: Release or Debug" CMAKE_BUILD_TYPE Debug )
else () # else Release
typed_cache_set ( STRING "Build type: Release or Debug" CMAKE_BUILD_TYPE Release )
endif()
endif()
# set optimizer flag
if ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
# set optimizer flag
if ( ${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
typed_cache_set (STRING "Optimizer" OPT "-g -ggdb")
else ()
else ()
typed_cache_set (STRING "Optimizer" OPT "-O3")
endif ()
endif ()
#typed_cache_set (STRING "compilation warnings" WARNCPP "-Waddress -Warray-bounds -Wc++0x-compat -Wchar-subscripts -Wenum-compare -Wcomment -Wformat -Wmain -Wmissing-braces -Wparentheses -Wreorder -Wreturn-type -Wsequence-point -Wsign-compare -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-label -Wunused-value -Wunused-variable -Wvolatile-register-var")
typed_cache_set (STRING "compilation warnings" WARNCPP "-Wall")
typed_cache_set (STRING "compilation warnings" WARNCPP "-Wall")
# check C compiler flags
include(CheckCCompilerFlag)
set (XX -Warray-bounds -Wchar-subscripts -Wcomment -Wformat -Wmain -Wmissing-braces -Wsequence-point -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused-label -Wvolatile-register-var)
set (WARNC_TMP "")
FOREACH(CWC ${XX})
# check C compiler flags
include(CheckCCompilerFlag)
set (XX -Warray-bounds -Wchar-subscripts -Wcomment -Wformat -Wmain -Wmissing-braces -Wsequence-point -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused-label -Wvolatile-register-var)
set (WARNC_TMP "")
FOREACH(CWC ${XX})
MESSAGE(STATUS "Test C options==> " ${CWC})
check_c_compiler_flag(${CWC} HAS_OPTION)
if (HAS_OPTION)
set(WARNC_TMP "${WARNC_TMP} ${CWC}")
endif()
endforeach()
typed_cache_set (STRING "compilation warnings" WARNC ${WARNC_TMP})
message(STATUS "Warnc = " ${WARNC} )
endforeach()
typed_cache_set (STRING "compilation warnings" WARNC ${WARNC_TMP})
message(STATUS "Warnc = " ${WARNC} )
typed_cache_set (STRING "compilation warnings" WARNF "-Wall" )
# just for testing
option(RELEASE "RELEASE " ON) # SHARED lib default
if ( NOT RELEASE ) # Debug TRUE
typed_cache_set (STRING "compilation warnings" WARNF "-Wall" )
# just for testing
option(RELEASE "RELEASE " ON) # SHARED lib default
if ( NOT RELEASE ) # Debug TRUE
typed_cache_set ( BOOL "RELEASE Version" RELEASE FALSE )
else () # else FALSE
typed_cache_set ( BOOL "RELEASE Version" RELEASE TRUE )
endif()
endif()
# detect MacOS
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# detect MacOS
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
typed_cache_set ( BOOL "OSX detection" OSX TRUE )
else()
else()
typed_cache_set ( BOOL "OSX detection" OSX FALSE )
endif()
endif()
# SHARED lib ?
option(BUILD_SHARED_LIBS "Shared lib " ON) # SHARED lib default
if ( NOT BUILD_SHARED_LIBS ) # Debug TRUE
# SHARED lib ?
option(BUILD_SHARED_LIBS "Shared lib " ON) # SHARED lib default
if ( NOT BUILD_SHARED_LIBS ) # Debug TRUE
typed_cache_set ( BOOL "Build SHARED" BUILD_SHARED_LIBS FALSE )
else () # else FALSE
typed_cache_set ( BOOL "Build SHARED" BUILD_SHARED_LIBS TRUE)
endif()
endif()
# set library type , SHARED or STATIC + LIB extension
if ( BUILD_SHARED_LIBS )
# set library type , SHARED or STATIC + LIB extension
if ( BUILD_SHARED_LIBS )
typed_cache_set ( STRING "LIB TYPE" LIBTYPE SHARED )
if (OSX)
typed_cache_set ( STRING "LIB TYPE" LIBEXT "dylib" )
......@@ -85,15 +83,15 @@ if ( BUILD_SHARED_LIBS )
typed_cache_set ( STRING "LIB TYPE" LIBEXT "so" )
endif()
else ()
else ()
typed_cache_set ( STRING "LIB TYPE" LIBTYPE STATIC )
typed_cache_set ( STRING "LIB TYPE" LIBEXT "a" )
endif()
endif()
if (UNSIO_INSTALLPATH)
if (UNSIO_INSTALLPATH)
typed_cache_set ( STRING "UNSIO loation" UNSIOPATH ${UNSIO_INSTALLPATH} )
endif()
#
endif()
#
endif( NOT SETUP_FLAGS_INCLUDED )
# ============================================================================
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment