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

CMake fixes for Roco2 #109

Merged
merged 6 commits into from
Jan 31, 2025
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
4 changes: 2 additions & 2 deletions cmake/BuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set_property(CACHE FIRESTARTER_BUILD_TYPE PROPERTY STRINGS FIRESTARTER FIRESTART

# Static linking is not supported with GPU devices or MacOS.
if(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(FIRESTARTER_LINK_STATIC "Link FIRESTARTER as a static binary. Note, dlopen is not supported in static binaries. This option is not available on macOS or with CUDA, OneAPI or HIP enabled." ON)
option(FIRESTARTER_LINK_STATIC "Link FIRESTARTER as a static binary. Note, dlopen is not supported in static binaries. This option is not available on macOS or with CUDA, OneAPI or HIP enabled." ON)
endif()


Expand All @@ -22,5 +22,5 @@ option(FIRESTARTER_FETCH_GOOGLETEST "Fetch the Google Test dependency." ON)

# Debug feature are enabled on linux per default.
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(FIRESTARTER_DEBUG_FEATURES "Enable debug features" ON)
option(FIRESTARTER_DEBUG_FEATURES "Enable debug features" ON)
endif()
6 changes: 5 additions & 1 deletion cmake/InstallHwloc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ if (FIRESTARTER_BUILD_HWLOC)
endif()
endif()

include_directories(${HWLOC_INCLUDE_DIR}/include)
add_dependencies(hwloc HwlocInstall)

# Including a non exsistant directory is not allowed. This is the case when configuring and hwloc is not yet installed.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/15052
file(MAKE_DIRECTORY "${HWLOC_INCLUDE_DIR}/include")
target_include_directories(hwloc INTERFACE "${HWLOC_INCLUDE_DIR}/include")
endif()
65 changes: 34 additions & 31 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ add_library(firestartercore STATIC
firestarter/X86/Payload/SSE2Payload.cpp
)

target_include_directories(firestartercore PUBLIC ${PROJECT_SOURCE_DIR}/include)

target_link_libraries(firestartercore
hwloc
AsmJit::AsmJit
Expand All @@ -53,21 +55,46 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
firestarter/Optimizer/Util/MultiObjective.cpp
firestarter/Optimizer/Algorithm/NSGA2.cpp
)

target_include_directories(firestarterlinux PUBLIC ${PROJECT_SOURCE_DIR}/include)

target_link_libraries(firestarterlinux
Nitro::log
nlohmann_json::nlohmann_json
)
endif()

add_library(firestartercombined STATIC
# IpcEstimateMetricData::insertValue is accesses which is part of the firestarterlinux library.
# This reference should be removed there and the file moved back to the firestartercore library.
firestarter/LoadWorker.cpp
)

target_link_libraries(firestartercombined
firestartercore
)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(firestartercombined
firestarterlinux
)
endif()

SET(FIRESTARTER_FILES
firestarter/Main.cpp
)

# IpcEstimateMetricData::insertValue is accesses which is part of the firestarterlinux library.
# This reference should be removed there and the file moved back to the firestartercore library.
firestarter/LoadWorker.cpp
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(FIRESTARTER_LIBRARIES
firestartercombined
)
else()
SET(FIRESTARTER_LIBRARIES
"-Wl,--whole-archive"
firestartercombined
"-Wl,--no-whole-archive"
)
endif()

if ("${FIRESTARTER_BUILD_TYPE}" STREQUAL "FIRESTARTER_CUDA")
add_executable(FIRESTARTER_CUDA
Expand All @@ -76,15 +103,9 @@ if ("${FIRESTARTER_BUILD_TYPE}" STREQUAL "FIRESTARTER_CUDA")
)

target_link_libraries(FIRESTARTER_CUDA
firestartercore
${FIRESTARTER_LIBRARIES}
)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(FIRESTARTER_CUDA
firestarterlinux
)
endif()

target_link_libraries(FIRESTARTER_CUDA
CUDA::cuda_driver
CUDA::cudart
Expand All @@ -110,15 +131,9 @@ elseif ("${FIRESTARTER_BUILD_TYPE}" STREQUAL "FIRESTARTER_ONEAPI")
)

target_link_libraries(FIRESTARTER_ONEAPI
firestartercore
${FIRESTARTER_LIBRARIES}
)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(FIRESTARTER_ONEAPI
firestarterlinux
)
endif()

target_link_libraries(FIRESTARTER_ONEAPI
mkl_sycl
mkl_intel_ilp64
Expand All @@ -136,15 +151,9 @@ elseif("${FIRESTARTER_BUILD_TYPE}" STREQUAL "FIRESTARTER_HIP")
)

target_link_libraries(FIRESTARTER_HIP
firestartercore
${FIRESTARTER_LIBRARIES}
)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(FIRESTARTER_HIP
firestarterlinux
)
endif()

target_link_libraries(FIRESTARTER_HIP
hip::host
hip::hiprand
Expand All @@ -164,15 +173,9 @@ elseif(${FIRESTARTER_BUILD_TYPE} STREQUAL "FIRESTARTER")
)

target_link_libraries(FIRESTARTER
firestartercore
${FIRESTARTER_LIBRARIES}
)

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(FIRESTARTER
firestarterlinux
)
endif()

target_link_libraries_darwin(NAME FIRESTARTER)

# static linking is not supported on Darwin, see Apple Technical QA1118
Expand Down
Loading