Commit 63673532 authored by COULAUD Olivier's avatar COULAUD Olivier

Introduce ScalFMM_CXX_FLAGS ; Fix bug with intel on MacOs X 10.x x>= 8

parent 799e9fc2
cmake_minimum_required (VERSION 2.8.3 FATAL_ERROR) cmake_minimum_required (VERSION 2.8.3 FATAL_ERROR)
cmake_policy(SET CMP0022 OLD)
cmake_policy(SET CMP0004 OLD)
# check if compiling into source directories # check if compiling into source directories
STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource) STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
if(insource) if(insource)
...@@ -10,7 +11,7 @@ endif(insource) ...@@ -10,7 +11,7 @@ endif(insource)
# MPI option has to be set before project, cannot be changed in the cache! # MPI option has to be set before project, cannot be changed in the cache!
if( ScalFMM_USE_MPI ) if( ScalFMM_USE_MPI )
include(CMakeForceCompiler) include(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER(mpicc "MPI C Compiler") CMAKE_FORCE_C_COMPILER(mpicc "MPI C Compiler")
CMAKE_FORCE_CXX_COMPILER(mpicxx "MPI C++ Compiler") CMAKE_FORCE_CXX_COMPILER(mpicxx "MPI C++ Compiler")
set(ScalFMM_USE_MPI ON CACHE BOOL "ScalFmm use MPI") set(ScalFMM_USE_MPI ON CACHE BOOL "ScalFmm use MPI")
else() else()
...@@ -51,62 +52,74 @@ OPTION( ScalFMM_USE_ADDONS "Set to ON to compile add ons" ...@@ -51,62 +52,74 @@ OPTION( ScalFMM_USE_ADDONS "Set to ON to compile add ons"
OPTION( ScalFMM_USE_SSE "Set to ON to compile with sse support" ON ) OPTION( ScalFMM_USE_SSE "Set to ON to compile with sse support" ON )
# Set scalfmm to default libraries # Set scalfmm to default libraries
SET(SCALFMM_LIBRARIES "") SET(SCALFMM_LIBRARIES "")
#
# Compile option
#
SET(ScaLFMM_CXX_FLAGS "-std=c++11 -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wconversion -fpic")
#
# Test if openmp is here # Test if openmp is here
#
find_package (OpenMP) find_package (OpenMP)
if(OPENMP_FOUND) if(OPENMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif() endif(OPENMP_FOUND)
MESSAGE(STATUS "ScalFMM_BUILD_DEBUG = ${ScalFMM_BUILD_DEBUG}" )
# Debug # Debug
MESSAGE( STATUS "ScalFMM_BUILD_DEBUG = ${ScalFMM_BUILD_DEBUG}" )
if( ScalFMM_BUILD_DEBUG ) if( ScalFMM_BUILD_DEBUG )
#
# Compile Debug flags
#
SET(CMAKE_BUILD_TYPE Debug) SET(CMAKE_BUILD_TYPE Debug)
ADD_DEFINITIONS(-O0) ADD_DEFINITIONS(-O0)
# Compile optimization
IF( APPLE ) IF( APPLE )
SET(SCALFMM_FLAGS_OPTI_DEBUG "-m64 -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.") SET(SCALFMM_FLAGS_OPTI_DEBUG "-m64 -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.")
ELSE() ELSE(APPLE)
# Test if not apple and 64bits # Test if not apple and 64bits
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(SCALFMM_FLAGS_OPTI_DEBUG "-m64 -march=native -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.") SET(SCALFMM_FLAGS_OPTI_DEBUG "-m64 -march=native -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.")
else() else()
SET(SCALFMM_FLAGS_OPTI_DEBUG "-march=native -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.") SET(SCALFMM_FLAGS_OPTI_DEBUG "-march=native -funroll-loops" CACHE STRING "Set your optimization flags for debug mode.")
endif() endif()
ENDIF() ENDIF(APPLE)
ADD_DEFINITIONS(${SCALFMM_FLAGS_OPTI_DEBUG}) # ADD_DEFINITIONS(${SCALFMM_FLAGS_OPTI_DEBUG})
SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} ${SCALFMM_FLAGS_OPTI_DEBUG}")
else() else()
#
# Compile Release flags
#
SET(CMAKE_BUILD_TYPE Release) SET(CMAKE_BUILD_TYPE Release)
# force -O2 in release # force -O2 in release
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2") SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
STRING(REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} ) STRING(REPLACE "-O3" "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} )
# if compiler is intel add -ip # if compiler is intel add -ip
IF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel") IF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
ADD_DEFINITIONS(-ip) SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} -ip")
ENDIF() ENDIF()
# Compile optimization # Compile optimization
IF( APPLE ) IF( APPLE )
SET(SCALFMM_FLAGS_OPTI_RELEASE "-m64 -ffast-math -funroll-loops" CACHE STRING "Set your optimization flags for release mode.") SET(SCALFMM_FLAGS_OPTI_RELEASE "-m64 -funroll-loops" CACHE STRING "Set your optimization flags for release mode.")
ELSE() ELSE(APPLE)
# Test if not apple and 64bits # Test if not apple and 64bits
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(SCALFMM_FLAGS_OPTI_RELEASE "-m64 -ffast-math -flto -march=native -funroll-loops" CACHE STRING "Set your optimization flags for release mode.") SET(SCALFMM_FLAGS_OPTI_RELEASE "-m64 -ffast-math -flto -march=native -funroll-loops" CACHE STRING "Set your optimization flags for release mode.")
else() else()
SET(SCALFMM_FLAGS_OPTI_RELEASE "-ffast-math -flto -march=native -funroll-loops" CACHE STRING "Set your optimization flags for release mode.") SET(SCALFMM_FLAGS_OPTI_RELEASE "-ffast-math -flto -march=native -funroll-loops" CACHE STRING "Set your optimization flags for release mode.")
endif() endif()
ENDIF() ENDIF(APPLE)
ADD_DEFINITIONS(${SCALFMM_FLAGS_OPTI_RELEASE}) # ADD_DEFINITIONS(${SCALFMM_FLAGS_OPTI_RELEASE})
SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} ${SCALFMM_FLAGS_OPTI_RELEASE}")
endif() endif()
#
# Attach source code to exec # Attach source code to exec
MESSAGE(STATUS "ScalFMM_ATTACHE_SOURCE = ${ScalFMM_ATTACHE_SOURCE}" ) MESSAGE(STATUS "ScalFMM_ATTACHE_SOURCE = ${ScalFMM_ATTACHE_SOURCE}" )
if( ScalFMM_ATTACHE_SOURCE ) if( ScalFMM_ATTACHE_SOURCE )
MESSAGE( STATUS "Option -g is used, the code is attached to the binary." ) MESSAGE( STATUS "Option -g is used, the code is attached to the binary." )
ADD_DEFINITIONS(-g) # ADD_DEFINITIONS(-g)
SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} -g")
endif() endif()
# Trace # Trace
...@@ -122,25 +135,27 @@ endif() ...@@ -122,25 +135,27 @@ endif()
if( ScalFMM_USE_BLAS ) if( ScalFMM_USE_BLAS )
OPTION( ScalFMM_USE_MKL_AS_BLAS "Set to ON to use MKL CBLAS" OFF ) OPTION( ScalFMM_USE_MKL_AS_BLAS "Set to ON to use MKL CBLAS" OFF )
if( ScalFMM_USE_MKL_AS_BLAS ) if( ScalFMM_USE_MKL_AS_BLAS )
SET(BLAS_LIBRARIES "-L$ENV{MKLROOT}/lib -lmkl_intel_lp64 -lmkl_sequential -lmkl_core" CACHE STRING "Set your MKL flags") SET(BLAS_LIBRARIES "-L$ENV{MKLROOT}/lib -lmkl_intel_lp64 -lmkl_sequential -lmkl_core" CACHE STRING "Set your MKL flags")
SET(LAPACK_LIBRARIES "")
elseif(ScalFMM_USE_EXTERNAL_BLAS) elseif(ScalFMM_USE_EXTERNAL_BLAS)
MESSAGE(STATUS "BLAS SET BY EXTERNAL PROGRAM = ${BLAS_LIBRARIES}") MESSAGE(STATUS "BLAS SET BY EXTERNAL PROGRAM = ${BLAS_LIBRARIES}")
else() else()
INCLUDE(FindBLAS) INCLUDE(FindBLAS)
INCLUDE(FindLAPACK) INCLUDE(FindLAPACK)
endif() endif()
#SET(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}") MESSAGE("BLAS_LIBRARIES ${BLAS_LIBRARIES}")
SET(SCALFMM_LIBRARIES ${SCALFMM_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}) MESSAGE(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}")
#MESSAGE(${SCALFMM_LIBRARIES}) SET(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES}")
endif() endif(ScalFMM_USE_BLAS)
# Compile option # Compile option
ADD_DEFINITIONS(-Wall -Wshadow -Wpointer-arith -Wcast-qual -Wconversion -fpic ) #ADD_DEFINITIONS(-Wall -Wshadow -Wpointer-arith -Wcast-qual -Wconversion -fpic )
# #
# C++ 2011 # C++ 2011
ADD_DEFINITIONS(-std=c++11) #ADD_DEFINITIONS(-std=c++11)
IF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND APPLE) IF(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND APPLE)
ADD_DEFINITIONS(-stdlib=libstdc++) SET(SCALFMM_LIBRARIES "${SCALFMM_LIBRARIES} -stdlib=libc++")
SET(ScaLFMM_CXX_FLAGS "${ScaLFMM_CXX_FLAGS} -stdlib=libc++")
endif() endif()
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/Src/ScalFmmConfig.h.cmake CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/Src/ScalFmmConfig.h.cmake
...@@ -236,3 +251,8 @@ SET(CPACK_SOURCE_IGNORE_FILES "\\\\.git;.DS_Store;.*~;/*.aux;/*.idx;/*.log;/*.ou ...@@ -236,3 +251,8 @@ SET(CPACK_SOURCE_IGNORE_FILES "\\\\.git;.DS_Store;.*~;/*.aux;/*.idx;/*.log;/*.ou
LIST(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}") LIST(APPEND CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}")
# #
INCLUDE(CPack) INCLUDE(CPack)
#
# OUTPUT
#
MESSAGE(STATUS "ScaLFMM_CXX_FLAGS: ${ScaLFMM_CXX_FLAGS}")
MESSAGE(STATUS "SCALFMM_LIBRARIES:-${SCALFMM_LIBRARIES}-")
...@@ -8,7 +8,8 @@ endif(insource) ...@@ -8,7 +8,8 @@ endif(insource)
project(Lib_scalfmm) project(Lib_scalfmm)
set(LIBRARY_OUTPUT_PATH ../lib/${CMAKE_BUILD_TYPE}) set(LIBRARY_OUTPUT_PATH ../lib/${CMAKE_BUILD_TYPE})
ADD_DEFINITIONS(${ScaLFMM_CXX_FLAGS})
MESSAGE( ${ScaLFMM_CXX_FLAGS})
# Searching all cpp file # Searching all cpp file
file( file(
GLOB_RECURSE GLOB_RECURSE
...@@ -26,8 +27,8 @@ add_library( ...@@ -26,8 +27,8 @@ add_library(
# Add blas library (even if it is set to off) # Add blas library (even if it is set to off)
target_link_libraries( target_link_libraries(
scalfmm scalfmm
${BLAS_LIBRARIES} ${scalfmm_lib}
${LAPACK_LIBRARIES} ${SCALFMM_LIBRARIES}
) )
# Adding the entire project dir as an include dir # Adding the entire project dir as an include dir
...@@ -54,5 +55,6 @@ FOREACH(my_dir ${my_include_dirs}) ...@@ -54,5 +55,6 @@ FOREACH(my_dir ${my_include_dirs})
) )
INSTALL( FILES ${hpp_in_dir} DESTINATION include/${my_dir} ) INSTALL( FILES ${hpp_in_dir} DESTINATION include/${my_dir} )
ENDFOREACH() ENDFOREACH()
INSTALL( FILES "${CMAKE_BINARY_DIR}/Src/ScalFmmConfig.h" DESTINATION include/Utils/${my_dir} ) INSTALL( FILES "${CMAKE_BINARY_DIR}/Src/ScalFmmConfig.h" DESTINATION include/Utils/${my_dir} )
...@@ -6,7 +6,7 @@ endif(insource) ...@@ -6,7 +6,7 @@ endif(insource)
project(Tests_scalfmm CXX) project(Tests_scalfmm CXX)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BUILD_TYPE}) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BUILD_TYPE})
ADD_DEFINITIONS( ${ScaLFMM_CXX_FLAGS})
# Find all code files # Find all code files
file( file(
GLOB_RECURSE GLOB_RECURSE
...@@ -54,7 +54,8 @@ foreach(exec ${source_tests_files}) ...@@ -54,7 +54,8 @@ foreach(exec ${source_tests_files})
${execname} ${execname}
${exec} ${exec}
) )
SET_TARGET_PROPERTIES(${execname} PROPERTIES
ENABLE_EXPORTS TRUE)
target_link_libraries( target_link_libraries(
${execname} ${execname}
${scalfmm_lib} ${scalfmm_lib}
......
...@@ -5,7 +5,9 @@ if(insource) ...@@ -5,7 +5,9 @@ if(insource)
endif(insource) endif(insource)
project(UTests_scalfmm CXX) project(UTests_scalfmm CXX)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BUILD_TYPE}) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BUILD_TYPE})
ADD_DEFINITIONS( ${ScaLFMM_CXX_FLAGS})
# Find all code files # Find all code files
file( file(
......
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