Skip to content

Commit

Permalink
Fixing CMake variables to allow for subproject builds
Browse files Browse the repository at this point in the history
  • Loading branch information
khuck committed Aug 13, 2021
1 parent 6bee392 commit a5b8d8c
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ endif()

# if the user didn't specify, set the installation directory.
if(NOT DEFINED CMAKE_INSTALL_PREFIX OR CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE STRING "APEX Installation directory" FORCE)
SET(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}" CACHE STRING "APEX Installation directory" FORCE)
endif()

# check if we are building for Kitten / LXK, and force some settings.
Expand Down
4 changes: 2 additions & 2 deletions cmake/Modules/APEX_Compile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ macro(apex_compile name)
set(${name}_RESULT "1")
endif()
endif()
file(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.${${name}_LANGUAGE}.stderr ${${name}_STDERR})
file(WRITE ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.${${name}_LANGUAGE}.stderr ${${name}_STDERR})
endif()
if(${name}_STDOUT)
file(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.${${name}_LANGUAGE}.stdout ${${name}_STDOUT})
file(WRITE ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${name}.${${name}_LANGUAGE}.stdout ${${name}_STDOUT})
endif()
endif()
endmacro()
Expand Down
8 changes: 4 additions & 4 deletions cmake/Modules/APEX_GCCVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apex_include(Option)

set(APEX_GCCVERSION_LOADED TRUE)

set(source_dir "${CMAKE_SOURCE_DIR}/cmake/tests")
set(source_dir "${PROJECT_SOURCE_DIR}/cmake/tests")

if(NOT MSVC)
include(APEX_Include)
Expand All @@ -24,17 +24,17 @@ if(NOT MSVC)
set(source_dir "$ENV{APEX_ROOT}/share/apex/cmake/tests")
endif()

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/config_tests)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/config_tests)

apex_compile(gcc_version SOURCE ${source_dir}/gcc_version.cpp
LANGUAGE CXX
OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/config_tests/gcc_version
OUTPUT ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/config_tests/gcc_version
FLAGS -I${BOOST_INCLUDE_DIR} ${include_dir})

if("${gcc_version_RESULT}" STREQUAL "0")
if(NOT GCC_VERSION)
execute_process(
COMMAND "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/config_tests/gcc_version"
COMMAND "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/config_tests/gcc_version"
OUTPUT_VARIABLE GCC_VERSION)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/Modules/APEX_SetupHPXMP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

add_library(hpxmp INTERFACE IMPORTED)
set_property(TARGET hpxmp PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${HPXMP_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/hpxmp/src)
INTERFACE_INCLUDE_DIRECTORIES ${HPXMP_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/hpxmp/src)
set_property(TARGET hpxmp PROPERTY
INTERFACE_LINK_LIBRARIES ${HPXMP_LIBRARIES})
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${HPXMP_LIBRARY_DIR})
Expand Down
6 changes: 3 additions & 3 deletions cmake/Modules/APEX_Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ include(APEX_Include)
apex_include(Message)

macro(apex_force_out_of_tree_build message)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
get_filename_component(parentdir ${CMAKE_SOURCE_DIR} PATH)
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${parentdir}" insourcesubdir)
string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" insource)
get_filename_component(parentdir ${PROJECT_SOURCE_DIR} PATH)
string(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${parentdir}" insourcesubdir)
if(insource OR insourcesubdir)
apex_error("in_tree" "${message}")
endif()
Expand Down
6 changes: 3 additions & 3 deletions src/apex/CMakeLists.hpx
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ endif()
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Get the current working tag
execute_process(
COMMAND git describe --abbrev=0 --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/scripts/apex_exec
${PROJECT_BINARY_DIR}/src/scripts/apex_exec @ONLY)
#INSTALL_FILES(bin FILES ${CMAKE_BINARY_DIR}/src/scripts/apex_exec)
#INSTALL_FILES(bin FILES ${PROJECT_BINARY_DIR}/src/scripts/apex_exec)


if (BUILD_STATIC_EXECUTABLES)
Expand Down
10 changes: 10 additions & 0 deletions src/scripts/apex_exec
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ where APEX options are zero or more of:
(python required for post-processing)
--apex:openacc enable OpenACC support
--apex:kokkos enable Kokkos support
--apex:kokkos_tuning enable Kokkos runtime autotuning support
--apex:raja enable RAJA support
--apex:pthread enable pthread wrapper support
--apex:memory enable memory wrapper support
Expand Down Expand Up @@ -71,6 +72,7 @@ where APEX options are zero or more of:

openacc=no
kokkos=no
kokkos_tuning=no
raja=no
otf2=no
gtrace=no
Expand Down Expand Up @@ -118,6 +120,11 @@ while (( "$#" )); do
kokkos=yes
shift
;;
--apex:kokkos_tuning)
kokkos=yes
kokkos_tuning=yes
shift
;;
--apex:raja)
raja=yes
shift
Expand Down Expand Up @@ -405,6 +412,9 @@ fi
if [ ${kokkos} = yes ] ; then
export KOKKOS_PROFILE_LIBRARY=${BASEDIR}/lib/libapex${SHLIBX}
fi
if [ ${kokkos_tuning} = yes ] ; then
export APEX_KOKKOS_TUNING=1
fi
if [ ${raja} = yes ] ; then
export RAJA_PLUGINS=${BASEDIR}/lib/libapex${SHLIBX}
fi
Expand Down

0 comments on commit a5b8d8c

Please sign in to comment.