diff --git a/CMakeLists.txt b/CMakeLists.txt index 49d345d48..730fe709b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,8 @@ set(LIBP_DEFINES "-DUSE_NULL_PROJECTION=1" CACHE STRING "Preprocessor macros for libparanumal") set(OCCA_CXX "${CMAKE_CXX_COMPILER}" CACHE STRING "C++ compiler for OCCA JIT compile") -set(OCCA_CXXFLAGS "" CACHE STRING "C++ flags for OCCA JIT compile") +set(OCCA_CXXFLAGS "-O2 -ftree-vectorize -funroll-loops -march=native -mtune=native" + CACHE STRING "C++ flags for OCCA JIT compile") set(OCCA_TAG "main" CACHE STRING "Git branch, tag, or hash for cloning OCCA") set(NEK5000_TAG "master" CACHE STRING "Git branch, tag, or hash for cloning Nek5000") @@ -97,6 +98,23 @@ set (CMAKE_CXX_STANDARD 14) ############################################################################### # Set compiler flags # ############################################################################### + +set(CMAKE_POSITION_INDEPENDENT_CODE on) + +# For CMake targets, CMAKE__FLAGS and CMAKE__FLAGS_ are +# both included automatically, based on the current . However, for +# external projects, we need to explicitly include both sets of flags + +function(set_external_flags lang) + string(TOUPPER "${CMAKE_BUILD_TYPE}" mode) + set(EXTERNAL_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${mode}}" + PARENT_SCOPE) +endfunction() + +set_external_flags("C") +set_external_flags("CXX") +set_external_flags("Fortran") + find_package(OpenMP) if (OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") @@ -104,8 +122,6 @@ if (OPENMP_FOUND) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") endif() -set(CMAKE_POSITION_INDEPENDENT_CODE on) - ############################################################################### # Generate nekrs.conf # ############################################################################### @@ -249,8 +265,9 @@ install(DIRECTORY src/nekInterface/ DESTINATION nekInterface REGEX "\.hpp$|\.cpp # Examples will follow a different policy -- only copy if source tree is newer than install tree file(GLOB_RECURSE EXAMPLE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/*) -configure_file(config/examples_manifest.cmake.in examples_manifest.cmake @ONLY) -install(SCRIPT config/install_examples.cmake) +configure_file(${CMAKE_CURRENT_LIST_DIR}/config/install_examples.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/install_examples.cmake @ONLY) +install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/install_examples.cmake) ################################################################################# # Uninstall diff --git a/config/examples_manifest.cmake.in b/config/examples_manifest.cmake.in deleted file mode 100644 index 4bd513df9..000000000 --- a/config/examples_manifest.cmake.in +++ /dev/null @@ -1,4 +0,0 @@ -set(EXAMPLE_FILES @EXAMPLE_FILES@) -set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@) -set(CURRENT_LIST_DIR @CMAKE_CURRENT_LIST_DIR@) -set(INSTALL_PREFIX @CMAKE_INSTALL_PREFIX@) diff --git a/config/gslib.cmake b/config/gslib.cmake index db77ed938..15f069dd3 100644 --- a/config/gslib.cmake +++ b/config/gslib.cmake @@ -27,7 +27,7 @@ ExternalProject_Add( BUILD_COMMAND ${CMAKE_CURRENT_LIST_DIR}/run_gs_install.sh "CC=${CMAKE_C_COMPILER}" - "CFLAGS=-fPIC ${CMAKE_C_FLAGS}" + "CFLAGS=-fPIC ${EXTERNAL_C_FLAGS}" INSTALL_COMMAND "" USES_TERMINAL_BUILD on ) @@ -73,7 +73,3 @@ install(DIRECTORY DESTINATION gatherScatter FILES_MATCHING REGEX ${file_pattern}) install(FILES ${OGS_SOURCE_DIR}/ogs.hpp DESTINATION gatherScatter) - - - - diff --git a/config/install_examples.cmake b/config/install_examples.cmake.in similarity index 69% rename from config/install_examples.cmake rename to config/install_examples.cmake.in index d17a15d0f..a63391c94 100644 --- a/config/install_examples.cmake +++ b/config/install_examples.cmake.in @@ -1,4 +1,7 @@ -include(examples_manifest.cmake) +set(EXAMPLE_FILES @EXAMPLE_FILES@) +set(CURRENT_SOURCE_DIR @CMAKE_CURRENT_SOURCE_DIR@) +set(CURRENT_LIST_DIR @CMAKE_CURRENT_LIST_DIR@) +set(INSTALL_PREFIX @CMAKE_INSTALL_PREFIX@) foreach(F IN LISTS EXAMPLE_FILES) FILE(RELATIVE_PATH REL_F ${CURRENT_LIST_DIR} ${F}) diff --git a/config/nek5000.cmake b/config/nek5000.cmake index 77ac1ef2c..cf55dfc20 100644 --- a/config/nek5000.cmake +++ b/config/nek5000.cmake @@ -110,9 +110,9 @@ ExternalProject_Add( BUILD_COMMAND ${CMAKE_CURRENT_LIST_DIR}/run_nekconfig.sh "CC=${CMAKE_C_COMPILER}" - "CFLAGS=${CMAKE_C_FLAGS}" + "CFLAGS=${EXTERNAL_C_FLAGS}" "FC=${CMAKE_Fortran_COMPILER}" - "FFLAGS=${CMAKE_Fortran_FLAGS}" + "FFLAGS=${EXTERNAL_Fortran_FLAGS}" "NEK5000_SOURCE_DIR=${NEK5000_SOURCE_DIR}" "PPLIST=${NEK5000_PPLIST}" INSTALL_COMMAND "" diff --git a/config/nekrs.conf.in b/config/nekrs.conf.in index bcafd41ef..cea1772cc 100644 --- a/config/nekrs.conf.in +++ b/config/nekrs.conf.in @@ -3,9 +3,9 @@ CXX = @CMAKE_CXX_COMPILER@ CC = @CMAKE_C_COMPILER@ FC = @CMAKE_Fortran_COMPILER@ -CXXFLAGS = @CMAKE_CXX_FLAGS@ -CFLAGS = @CMAKE_C_FLAGS@ -FFLAGS = @CMAKE_Fortran_FLAGS@ +CXXFLAGS = @EXTERNAL_CXX_FLAGS@ +CFLAGS = @EXTERNAL_C_FLAGS@ +FFLAGS = @EXTERNAL_Fortran_FLAGS@ NEK5000_PPLIST = @NEK5000_PPLIST@ LIBP_DEFINES = @LIBP_DEFINES@