-
Notifications
You must be signed in to change notification settings - Fork 15
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
Refactor cmake build system #134
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,10 @@ cmake_minimum_required(VERSION 3.12) | |
|
||
project(PerfFlowAspect VERSION "0.1.0") | ||
|
||
# Fail if someone tries to config an in-source build. | ||
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") | ||
message(FATAL_ERROR "In-source builds are not supported. Please remove " | ||
"CMakeCache.txt from the 'src' dir and configure an " | ||
"out-of-source build in another directory.") | ||
endif() | ||
# Build Options | ||
option(PERFFLOWASPECT_WITH_CUDA "Build CUDA smoketest" ON) | ||
option(PERFFLOWASPECT_WITH_MPI "Build MPI smoketest" ON) | ||
option(PERFFLOWASPECT_WITH_MULTITHREADS "Build multi-threaded smoketest" ON) | ||
|
||
# Fail if using Clang < 9.0 | ||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
|
@@ -24,30 +22,15 @@ else() | |
message(WARNING "Unsupported CXX compiler: please use Clang >= 9.0") | ||
endif() | ||
|
||
# Always use position independent code | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Set build type | ||
set(default_build_type "Debug") | ||
|
||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Using default build type: \"${default_build_type}\"") | ||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE | ||
STRING "Choose the type of build." FORCE) | ||
# Set the possible values of build type for cmake-gui | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") | ||
else() | ||
message(STATUS "Setting build type to \"${CMAKE_BUILD_TYPE}\"") | ||
endif() | ||
include(cmake/CMakeBasics.cmake) | ||
|
||
include(cmake/Setup3rdParty.cmake) | ||
|
||
include(GNUInstallDirs) | ||
set(CMAKE_SKIP_BUILD_RPATH FALSE) | ||
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) | ||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) | ||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revisit setting rpath |
||
message(STATUS "CMAKE_INSTALL_RPATH = ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") | ||
|
||
|
||
# the RPATH to be used when installing, but only if it's not a system directory | ||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES | ||
|
@@ -56,7 +39,6 @@ if("${isSystemDir}" STREQUAL "-1") | |
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") | ||
endif("${isSystemDir}" STREQUAL "-1") | ||
|
||
|
||
add_subdirectory(parser) | ||
add_subdirectory(runtime) | ||
add_subdirectory(weaver) | ||
|
@@ -66,19 +48,20 @@ add_library(perfflowaspect INTERFACE) | |
target_link_libraries(perfflowaspect INTERFACE perfflow_runtime perfflow_parser WeavePassPlugin) | ||
install(TARGETS perfflowaspect | ||
EXPORT perfflow_export | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
) | ||
|
||
add_subdirectory(config) | ||
|
||
message(STATUS "Config Dir: ${PERFFLOWASPECT_INSTALL_CONFIG_DIR}") | ||
|
||
if (NOT DEFINED PERFFLOWASPECT_INSTALL_CONFIG_DIR) | ||
if(NOT DEFINED PERFFLOWASPECT_INSTALL_CONFIG_DIR) | ||
set(PERFFLOWASPECT_INSTALL_CONFIG_DIR "share") | ||
endif() | ||
|
||
message(STATUS "CMAKE_INSTALL_RPATH = ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") | ||
message(STATUS "Config Dir: ${CMAKE_INSTALL_PREFIX}/${PERFFLOWASPECT_INSTALL_CONFIG_DIR}") | ||
|
||
install(EXPORT perfflow_export | ||
FILE perfflowaspect_targets.cmake | ||
NAMESPACE perfflowaspect:: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Fail if someone tries to config an in-source build. | ||
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") | ||
message(FATAL_ERROR "In-source builds are not supported. Please remove " | ||
"CMakeCache.txt from the 'src' dir and configure an " | ||
"out-of-source build in another directory.") | ||
endif() | ||
|
||
# Always use position independent code | ||
set(CMAKE_POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Set build type | ||
set(default_build_type "Debug") | ||
|
||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) | ||
message(STATUS "Using default build type: \"${default_build_type}\"") | ||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) | ||
# Set the possible values of build type for cmake-gui | ||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") | ||
else() | ||
message(STATUS "Setting build type to \"${CMAKE_BUILD_TYPE}\"") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
include(cmake/thirdparty/FindBison.cmake) | ||
|
||
if(PERFFLOWASPECT_WITH_CUDA) | ||
include(cmake/thirdparty/FindCUDA.cmake) | ||
endif() | ||
|
||
include(cmake/thirdparty/FindFlex.cmake) | ||
|
||
include(cmake/thirdparty/FindJansson.cmake) | ||
|
||
include(cmake/thirdparty/FindLLVM.cmake) | ||
|
||
if(PERFFLOWASPECT_WITH_MPI) | ||
include(cmake/thirdparty/FindMPI.cmake) | ||
endif() | ||
|
||
include(cmake/thirdparty/FindOpenSSL.cmake) | ||
|
||
if(PERFFLOWASPECT_WITH_MULTITHREADS) | ||
include(cmake/thirdparty/FindThreads.cmake) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
find_package(BISON REQUIRED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
find_package(CUDA) | ||
|
||
if(PERFFLOWASPECT_WITH_CUDA) | ||
message(STATUS "Building CUDA smoketest (PERFFLOWASPECT_WITH_CUDA == ON)") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
find_package(FLEX REQUIRED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# First check for user-specified JANSSON_DIR | ||
if(JANSSON_DIR) | ||
message(STATUS "Looking for Jansson using JANSSON_DIR = ${JANSSON_DIR}") | ||
|
||
find_path(JANSSON_INCLUDE_DIRS | ||
NAMES jansson.h | ||
HINTS ${JANSSON_DIR}/include | ||
) | ||
if(NOT JANSSON_INCLUDE_DIRS) | ||
MESSAGE(FATAL_ERROR "Could not find jansson.h in ${JANSSON_DIR}/include") | ||
endif() | ||
|
||
find_library(JANSSON_LIBRARY | ||
NAMES libjansson.so | ||
HINTS ${JANSSON_DIR}/lib | ||
) | ||
if(NOT JANSSON_LIBRARY) | ||
MESSAGE(FATAL_ERROR "Could not find libjansson.so in ${JANSSON_DIR}/lib") | ||
endif() | ||
|
||
set(JANSSON_FOUND TRUE CACHE INTERNAL "") | ||
set(JANSSON_DIR ${JANSSON_DIR} CACHE PATH "" FORCE) | ||
include_directories(${JANSSON_INCLUDE_DIRS}) | ||
|
||
message(STATUS "FOUND jansson") | ||
message(STATUS " [*] JANSSON_DIR = ${JANSSON_DIR}") | ||
message(STATUS " [*] JANSSON_INCLUDE_DIRS = ${JANSSON_INCLUDE_DIRS}") | ||
message(STATUS " [*] JANSSON_LIBRARY = ${JANSSON_LIBRARY}") | ||
# If JANSSON_DIR not specified, then try to automatically find the JANSSON header | ||
# and library | ||
elseif(NOT JANSSON_FOUND) | ||
find_path(JANSSON_INCLUDE_DIRS | ||
NAMES jansson.h | ||
) | ||
|
||
find_library(JANSSON_LIBRARY | ||
NAMES libjansson.so | ||
) | ||
|
||
if(JANSSON_INCLUDE_DIRS AND JANSSON_LIBRARY) | ||
set(JANSSON_FOUND TRUE CACHE INTERNAL "") | ||
set(JANSSON_INCLUDE_DIRS ${JANSSON_INCLUDE_DIRS} CACHE PATH "" FORCE) | ||
set(JANSSON_LIBRARY ${JANSSON_LIBRARY} CACHE PATH "" FORCE) | ||
include_directories(${JANSSON_INCLUDE_DIRS}) | ||
|
||
message(STATUS "FOUND jansson using find_library()") | ||
message(STATUS " [*] JANSSON_INCLUDE_DIRS = ${JANSSON_INCLUDE_DIRS}") | ||
message(STATUS " [*] JANSSON_LIBRARY = ${JANSSON_LIBRARY}") | ||
endif() | ||
endif() | ||
|
||
# Abort if all methods fail | ||
if(NOT JANSSON_FOUND) | ||
message(FATAL_ERROR "Jansson support needs explict JANSSON_DIR") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
find_package(LLVM REQUIRED CONFIG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
find_package(MPI REQUIRED) | ||
|
||
if(PERFFLOWASPECT_WITH_MPI) | ||
message(STATUS "Building MPI smoketest (PERFFLOWASPECT_WITH_MPI == ON)") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
find_package(OpenSSL REQUIRED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
find_package(Threads REQUIRED) | ||
|
||
if(PERFFLOWASPECT_WITH_MULTITHREADS) | ||
message(STATUS "Building multi-threaded smoketest (PERFFLOWASPECT_WITH_MULTITHREADS == ON)") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
# support C++14 features used by LLVM 10.0.0 | ||
set(CMAKE_CXX_STANDARD 14) | ||
|
||
find_package(LLVM REQUIRED CONFIG) | ||
add_definitions(${LLVM_DEFINITIONS}) | ||
include_directories(${LLVM_INCLUDE_DIRS}) | ||
link_directories(${LLVM_LIBRARY_DIRS}) | ||
if(LLVM_FOUND) | ||
add_definitions(${LLVM_DEFINITIONS}) | ||
include_directories(${LLVM_INCLUDE_DIRS}) | ||
link_directories(${LLVM_LIBRARY_DIRS}) | ||
endif() | ||
|
||
add_subdirectory(weave) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a single build option for all tests, tests will build only if it exists (e.g. CUDA for example)