-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an initial FLAME GPU 2 model (Circle) with an empty test suite
- Loading branch information
Showing
12 changed files
with
1,066 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,46 @@ | ||
# Minimum CMake version 3.18 for CUDA --std=c++17 | ||
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR) | ||
|
||
# Optionally set the version of flamegpu which should be used, ideally a tag (i.e. `v2.0.0-rc`) or branch name, or potentially a commit hash. | ||
set(FLAMEGPU_VERSION "v2.0.0-rc.1" CACHE STRING "FLAMEGPU/FLAMEGPU2 git branch or tag to use") | ||
# If the above version is a hash instead, also set FLAMEGPU_VERSION_ALLOW_HASH to ON | ||
# set(FLAMEGPU_VERSION_ALLOW_HASH "ON") | ||
|
||
# Manually specify the FLAMEGPU_VISUALISATION option to provide it prior to original configuration and allow the default to be overridden in the downstream project | ||
option(FLAMEGPU_VISUALISATION "Enable FLAMEGPU visualisation support" OFF) | ||
|
||
# Our core dependency is FLAMEGPU2 lib, first lets find it | ||
include(${CMAKE_CURRENT_LIST_DIR}/cmake/flamegpu2.cmake) | ||
|
||
# Handle CMAKE_CUDA_ARCHITECTURES gracefully, passing the project name for code-injection | ||
include(${FLAMEGPU_ROOT}/cmake/CUDAArchitectures.cmake) | ||
flamegpu_init_cuda_architectures(PROJECT exatepp_abm) | ||
|
||
# Name the project and set languages, this must be done after flamegpu_init_cuda_architectures | ||
project(exatepp_abm CUDA CXX) | ||
|
||
# Detect if we are the top level CMake file or not (for CMake < 3.21) | ||
if(CMAKE_VERSION VERSION_LESS "3.21" AND CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) | ||
set(PROJECT_IS_TOP_LEVEL ON) | ||
endif() | ||
|
||
# Option to enable building / enabling tests | ||
option(BUILD_TESTING "Build the testing tree." OFF) | ||
# Option to enable google test test discovery | ||
cmake_dependent_option(ENABLE_GTEST_DISCOVER "Enable GTEST_DISCOVER for more detailed ctest output without -VV. This dramatically increases test suite runtime to CUDA context initialisation." OFF "BUILD_TESTING" OFF) | ||
|
||
# Include common rules from the FLAMEGPU/FLAMEGPU2 repositories CMake | ||
include(${FLAMEGPU_ROOT}/cmake/common.cmake) | ||
|
||
# Define output location of binary files | ||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/) | ||
|
||
# Add the child CMakeLists.txt which defines the static library and binary. | ||
add_subdirectory(src "${PROJECT_BINARY_DIR}/exatepp_abm") | ||
|
||
# --- | ||
# If testing is enabled and we are the top level cmake, add the test directory. | ||
if(BUILD_TESTING AND PROJECT_IS_TOP_LEVEL) # OR FRE_BUILD_TESTING @todo? | ||
enable_testing() | ||
add_subdirectory(tests) | ||
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,41 @@ | ||
############## | ||
# GOOGLETEST # | ||
############## | ||
|
||
include(FetchContent) | ||
cmake_policy(SET CMP0079 NEW) | ||
|
||
# Googltest newer than 389cb68b87193358358ae87cc56d257fd0d80189 (included in release-1.11.0) or newer is required for CMake >= 3.19 | ||
FetchContent_Declare( | ||
googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG release-1.11.0 | ||
) | ||
|
||
FetchContent_GetProperties(googletest) | ||
if(NOT googletest_POPULATED) | ||
FetchContent_Populate(googletest) | ||
# Suppress installation target, as this makes a warning | ||
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) | ||
mark_as_advanced(FORCE INSTALL_GTEST) | ||
mark_as_advanced(FORCE BUILD_GMOCK) | ||
# Prevent overriding the parent project's compiler/linker | ||
# settings on Windows | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
# Set the folder to use | ||
if (DEFINED flamegpu_set_target_folder) | ||
flamegpu_set_target_folder(gtest "Tests/Dependencies") | ||
endif() | ||
# Disable compiler warnings | ||
if(TARGET gtest) | ||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
target_compile_options(gtest PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:/W0>") | ||
else() | ||
target_compile_options(gtest PRIVATE "$<$<COMPILE_LANGUAGE:C,CXX>:-w>") | ||
endif() | ||
# Always tell nvcc to disable warnings | ||
target_compile_options(gtest PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:-w>") | ||
endif() | ||
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,75 @@ | ||
include(FetchContent) | ||
cmake_policy(SET CMP0079 NEW) | ||
|
||
# If overridden by the user, attempt to use that | ||
if (FLAMEGPU_ROOT) | ||
# Look for the main flamegpu.h header to get the abs path, but only look relative to the hints/paths, no cmake defaults. Do not cache the result. | ||
set(FLAMEGPU_INCLUDE_HEADER_FILE include/flamegpu/flamegpu.h) | ||
find_path(FLAMEGPU_ROOT_ABS | ||
NAMES | ||
${FLAMEGPU_INCLUDE_HEADER_FILE} | ||
HINTS | ||
${FLAMEGPU_ROOT} | ||
PATHS | ||
${FLAMEGPU_ROOT} | ||
NO_DEFAULT_PATH | ||
NO_CACHE | ||
) | ||
# If found, use the local flamegpu, otherwise error. | ||
if(FLAMEGPU_ROOT_ABS) | ||
# If the correct flamegpu root was found, output a successful status message | ||
message(STATUS "Found FLAMEGPU_ROOT: ${FLAMEGPU_ROOT_ABS} (${FLAMEGPU_ROOT})") | ||
# update the value to the non abs version, in local and parent scope. | ||
set(FLAMEGPU_ROOT "${FLAMEGPU_ROOT_ABS}") | ||
# And set up the flamegpu build | ||
add_subdirectory(${FLAMEGPU_ROOT_ABS} ${CMAKE_CURRENT_BINARY_DIR}/_deps/flamegpu2-build) | ||
else() | ||
# Send a fatal error if the flamegpu root passed is invalid. | ||
message(FATAL_ERROR "Invalid FLAMEGPU_ROOT '${FLAMEGPU_ROOT}'.\nFLAMEGPU_ROOT must be a valid directory containing '${FLAMEGPU_INCLUDE_HEADER_FILE}'") | ||
endif() | ||
else() | ||
# If a FLAMEGPU_VERSION has not been defined, set it to the default option. | ||
if(NOT DEFINED FLAMEGPU_VERSION OR FLAMEGPU_VERSION STREQUAL "") | ||
set(FLAMEGPU_VERSION "master" CACHE STRING "Git branch or tag to use") | ||
endif() | ||
|
||
# If the FLAME GPU version is a hash not a branch or tag, | ||
if(NOT DEFINED FLAMEGPU_VERSION_ALLOW_HASH OR FLAMEGPU_VERSION_ALLOW_HASH STREQUAL "") | ||
set(FLAMEGPU_VERSION_ALLOW_HASH "OFF" CACHE BOOL "Boolean to enable use of a git hash in FLAMEGPU_VERSION. This will slow down CMake configuration.") | ||
endif() | ||
|
||
# Allow users to switch to forks with relative ease. | ||
if(NOT DEFINED FLAMEGPU_REPOSITORY OR FLAMEGPU_REPOSITORY STREQUAL "") | ||
set(FLAMEGPU_REPOSITORY "https://github.com/FLAMEGPU/FLAMEGPU2.git" CACHE STRING "Remote Git Repository for FLAME GPU 2+") | ||
endif() | ||
|
||
# CMake does not support simple negation, so map to a differnt non cache variable to invert to the correct truthyness for GIT_SHALLOW | ||
set(USE_GIT_SHALLOW "ON") | ||
if(FLAMEGPU_VERSION_ALLOW_HASH) | ||
set(USE_GIT_SHALLOW OFF) | ||
endif() | ||
# Declare the fetch content target usign the above optional variables | ||
FetchContent_Declare( | ||
flamegpu2 | ||
GIT_REPOSITORY ${FLAMEGPU_REPOSITORY} | ||
GIT_TAG ${FLAMEGPU_VERSION} | ||
GIT_SHALLOW ${USE_GIT_SHALLOW} | ||
GIT_PROGRESS ON | ||
# UPDATE_DISCONNECTED ON | ||
) | ||
unset(USE_GIT_SHALLOW) | ||
|
||
# Fetch and populate the content if required. | ||
FetchContent_GetProperties(flamegpu2) | ||
if(NOT flamegpu2_POPULATED) | ||
FetchContent_Populate(flamegpu2) | ||
mark_as_advanced(FORCE BUILD_TESTS) | ||
# Add the subdirectory | ||
add_subdirectory(${flamegpu2_SOURCE_DIR} ${flamegpu2_BINARY_DIR}) | ||
# Add flamegpu2' expected location to the prefix path. | ||
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${flamegpu2_SOURCE_DIR}/cmake") | ||
endif() | ||
|
||
message(STATUS "Found FLAMEGPU2 ${flamegpu2_SOURCE_DIR}") | ||
set(FLAMEGPU_ROOT ${flamegpu2_SOURCE_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,3 @@ | ||
set noparent | ||
linelength=320 | ||
filter=-legal/copyright,-readability/todo,-runtime/references,-build/c++11 |
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,63 @@ | ||
# Minimum CMake version 3.18 for CUDA --std=c++17 | ||
cmake_minimum_required(VERSION 3.18...3.25 FATAL_ERROR) | ||
|
||
# This CMakeLists should not be built on its own. | ||
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") | ||
message(FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR} cannot be the top CMakeLists.txt. Please use the parent directory") | ||
endif() | ||
|
||
# We already have a project here, no need to reset one, but set variables for the target names | ||
set(LIBRARY_NAME "${PROJECT_NAME}_lib") | ||
set(BINARY_NAME "${PROJECT_NAME}") | ||
|
||
# -------------------------------------------- | ||
# Define the static library target | ||
# -------------------------------------------- | ||
SET(LIBRARY_SRC | ||
${CMAKE_CURRENT_SOURCE_DIR}/exatepp_abm.h | ||
${CMAKE_CURRENT_SOURCE_DIR}/exatepp_abm.cu | ||
) | ||
|
||
flamegpu_add_library("${LIBRARY_NAME}" "${LIBRARY_SRC}" "${FLAMEGPU_ROOT}" "${PROJECT_BINARY_DIR}" FALSE) | ||
|
||
|
||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
# Prevent windows.h definition of MIN and MAX macros on windows | ||
target_compile_definitions(${LIBRARY_NAME} PRIVATE NOMINMAX) | ||
# Allow use of M_PI anywhere | ||
target_compile_definitions(${LIBRARY_NAME} PRIVATE _USE_MATH_DEFINES) | ||
endif() | ||
|
||
# Add src directory to include path | ||
target_include_directories("${LIBRARY_NAME}" PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") | ||
|
||
# -------------------------------------------- | ||
# Define the binary target | ||
# -------------------------------------------- | ||
set(SRC ${CMAKE_CURRENT_SOURCE_DIR}/main.cu) | ||
flamegpu_add_executable("${BINARY_NAME}" "${SRC}" "${FLAMEGPU_ROOT}" "${PROJECT_BINARY_DIR}" FALSE) | ||
|
||
|
||
# Link against the static library target. | ||
target_link_libraries("${BINARY_NAME}" PRIVATE "${LIBRARY_NAME}") | ||
|
||
|
||
# -------------------------------------------- | ||
# Define shorthand lint target | ||
# -------------------------------------------- | ||
|
||
# Create a target named lint which calls the generated lint_exatepp_abm and lint_exatepp_abm_lib targets | ||
# Create an alias target `lint` for `lint_fujitsu_iow` out of laziness | ||
if(TARGET lint_${LIBRARY_NAME}) | ||
if(NOT TARGET lint) | ||
add_custom_target(lint) | ||
set_target_properties(lint PROPERTIES EXCLUDE_FROM_ALL TRUE) | ||
flamegpu_set_target_folder(lint "Lint") | ||
endif() | ||
add_dependencies(lint lint_${LIBRARY_NAME}) | ||
endif() | ||
|
||
# Make linting the binary also lint the static library, to keep prior behaviour | ||
if(TARGET lint_${BINARY_NAME} AND TARGET lint_${LIBRARY_NAME}) | ||
add_dependencies(lint_${BINARY_NAME} lint_${LIBRARY_NAME}) | ||
endif() |
Oops, something went wrong.