Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flags for subproject builds, propagating flags to external build #118

Merged
merged 5 commits into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -97,15 +98,30 @@ set (CMAKE_CXX_STANDARD 14)
###############################################################################
# Set compiler flags #
###############################################################################

set(CMAKE_POSITION_INDEPENDENT_CODE on)

# For CMake targets, CMAKE_<LANG>_FLAGS and CMAKE_<LANG>_FLAGS_<CONFIG> are
# both included automatically, based on the current <CONFIG>. 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}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

set(CMAKE_POSITION_INDEPENDENT_CODE on)

###############################################################################
# Generate nekrs.conf #
###############################################################################
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions config/examples_manifest.cmake.in

This file was deleted.

6 changes: 1 addition & 5 deletions config/gslib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -73,7 +73,3 @@ install(DIRECTORY
DESTINATION gatherScatter
FILES_MATCHING REGEX ${file_pattern})
install(FILES ${OGS_SOURCE_DIR}/ogs.hpp DESTINATION gatherScatter)




Original file line number Diff line number Diff line change
@@ -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})
Expand Down
4 changes: 2 additions & 2 deletions config/nek5000.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
6 changes: 3 additions & 3 deletions config/nekrs.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@
Expand Down