From 76df6d153d30309fae4d9b9d54ad258b91b917b1 Mon Sep 17 00:00:00 2001 From: RonRahaman Date: Thu, 23 Jul 2020 12:36:03 -0500 Subject: [PATCH 1/3] Fixes for subproj builds and propagating flags to external build --- CMakeLists.txt | 25 ++++++++++++++++++++++--- config/gslib.cmake | 6 +----- config/nek5000.cmake | 4 ++-- config/nekrs.conf.in | 6 +++--- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49d345d48..2d3c19887 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,26 @@ 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) + set(EXTERNAL_${lang}_FLAGS +"${CMAKE_${lang}_FLAGS} \ +$<$:${CMAKE_${lang}_FLAGS_DEBUG}> \ +$<$:${CMAKE_${lang}_FLAGS_RELEASE}> \ +$<$:${CMAKE_${lang}_FLAGS_RELWITHDEBINFO}>" + 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 +125,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 # ############################################################################### 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/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@ From f59de40bbcf1fcd415026fbdf66a1199c9574a72 Mon Sep 17 00:00:00 2001 From: RonRahaman Date: Thu, 23 Jul 2020 13:29:44 -0500 Subject: [PATCH 2/3] Fixed generator expression in CMakeLists --- CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d3c19887..6a56f766f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,12 +106,9 @@ set(CMAKE_POSITION_INDEPENDENT_CODE on) # external projects, we need to explicitly include both sets of flags function(set_external_flags lang) - set(EXTERNAL_${lang}_FLAGS -"${CMAKE_${lang}_FLAGS} \ -$<$:${CMAKE_${lang}_FLAGS_DEBUG}> \ -$<$:${CMAKE_${lang}_FLAGS_RELEASE}> \ -$<$:${CMAKE_${lang}_FLAGS_RELWITHDEBINFO}>" - PARENT_SCOPE) + string(TOUPPER ${CMAKE_BUILD_TYPE} mode) + set(EXTERNAL_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${mode}}" + PARENT_SCOPE) endfunction() set_external_flags("C") From 43b96a3d4f95d9dc9db78be39d6560bcaa7ee68e Mon Sep 17 00:00:00 2001 From: RonRahaman Date: Fri, 24 Jul 2020 11:34:06 -0500 Subject: [PATCH 3/3] WIP: Fixed script output locations for subproject --- CMakeLists.txt | 7 ++++--- config/examples_manifest.cmake.in | 4 ---- .../{install_examples.cmake => install_examples.cmake.in} | 5 ++++- 3 files changed, 8 insertions(+), 8 deletions(-) delete mode 100644 config/examples_manifest.cmake.in rename config/{install_examples.cmake => install_examples.cmake.in} (69%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a56f766f..730fe709b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,7 +106,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE on) # external projects, we need to explicitly include both sets of flags function(set_external_flags lang) - string(TOUPPER ${CMAKE_BUILD_TYPE} mode) + string(TOUPPER "${CMAKE_BUILD_TYPE}" mode) set(EXTERNAL_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${CMAKE_${lang}_FLAGS_${mode}}" PARENT_SCOPE) endfunction() @@ -265,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/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})