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

[WIP] Introduced CMake based build procedure and first unit/funcitonal tests created #193

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f5870d4
Moved to CMake build (WIP)
ChristopherBignamini Mar 22, 2024
9a4e8fe
Cleanup
ChristopherBignamini Mar 30, 2024
17ba799
Missing include added
ChristopherBignamini Mar 30, 2024
c5ddafe
Test setup cmake file added
ChristopherBignamini Mar 30, 2024
dc1ddb6
C wrappers folder and interpolator wrappers created
ChristopherBignamini Mar 30, 2024
75e62cc
Intepolation unit test created (input/reference value tbd)
ChristopherBignamini Mar 30, 2024
e34fbfa
Chemistry local solve functional test added
ChristopherBignamini Apr 16, 2024
90b8288
Auto-generated files temporarily added to src/clib/generated folder
ChristopherBignamini Apr 17, 2024
4bdbe2b
Merge remote-tracking branch 'upstream/main' into main
ChristopherBignamini Apr 17, 2024
ac26deb
Missing source file added
ChristopherBignamini Apr 17, 2024
5b4c8b5
Example GTest created
ChristopherBignamini Sep 16, 2024
54491c3
Redundant line removed
ChristopherBignamini Sep 26, 2024
103d541
CI config update for GTests execution
ChristopherBignamini Sep 27, 2024
3e7ae54
Update to GTest zip downloading instead of cloning
ChristopherBignamini Sep 27, 2024
99e438b
Automated test discovery and LINUX option issue fixed
ChristopherBignamini Sep 27, 2024
c084a64
Test build flag naming updated
ChristopherBignamini Sep 27, 2024
5a06f1b
Cmake files cleanup and comments added
ChristopherBignamini Sep 30, 2024
f1e674a
Merge remote-tracking branch 'origin/gtest_integration' into main
ChristopherBignamini Oct 1, 2024
b75c050
Source folder reorganization
ChristopherBignamini Oct 1, 2024
3820fdb
Folder deleted
ChristopherBignamini Oct 1, 2024
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
11 changes: 11 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,17 @@ jobs:
build_kind: 'cmake'
generate: 'false'

- run:
name: "Execute the C++ tests"
command: |
# compile the tests (it would probably would be better to do this when
# compiling the rest of Grackle)
cmake -DGRACKLE_BUILD_TESTS=ON -Bbuild
cmake --build build
# execute the tests
cd build
ctest

# TODO: once we merge in GH-#208, we need to issue a new gold standard, and then we should
# issue a followup PR where we uncomment the remainder of this test
test-standalone-pygrackle:
Expand Down
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ endif()
cmake_minimum_required(VERSION 3.16)
cmake_policy(SET CMP0077 NEW)
cmake_policy(SET CMP0082 NEW)

if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
cmake_policy(SET CMP0135 NEW) # makes automatic dependency downloads more
# robust (& addresses noisy warnings)
endif()

project(Grackle VERSION ${_GRACKLE_VERSION_NO_DEVTAG} LANGUAGES C CXX Fortran)

# Specify that `./cmake` contains cmake modules defining useful functionality
Expand Down Expand Up @@ -184,6 +190,21 @@ endif()
# -----
# (this is where we will add targets for integration tests)

# Add BUILD_TESTS option available
option(GRACKLE_BUILD_TESTS "build Grackle tests using GoogleTest" OFF)

# if desired, setup Grackle's tests that use GoogleTest (this has no impact on
# the tests run via pytest, those are handled outside of cmake)
if(GRACKLE_BUILD_TESTS)
# setup GoogleTest framework (search for an installed copy on the machine
# OR download it & add its compilation to the rest of the build procedure)
include(setup_GTest)
# load CMake's built-in module that defines functions to registering unit
# tests implemented with GoogleTest into CMake's test-runner, CTest
include(GoogleTest)
enable_testing() # enable the test-runner, CTest
add_subdirectory(tests) # declare the recipes for each test
endif()

# Packaging
# ---------
Expand Down
35 changes: 35 additions & 0 deletions cmake/setup_GTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This file includes logic for setting up GoogleTest
find_package(GTest)

if (NOT GTest_FOUND)
message(STATUS
"Preparing to download GTest from GitHub & configure its build. Don't "
"worry about any mentions of Python in the following text -- that is "
"only used internally by the Google test build"
)

# NOTE: it is idiomatic to use FetchContent with a git hash rather than the
# name of a tag or branch (since the latter 2 can freely change). If we use
# the name of a tag/branch, then CMake will query GitHub on every
# subsequent build to check whether the tag/branch is still the same

include(FetchContent)
FetchContent_Declare(
googletest # the url contains the hash for v1.13.0
URL https://github.com/google/googletest/archive/b796f7d44681514f58a683a3a71ff17c94edb0c1.zip
)

# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

elseif("${CMAKE_VERSION}" VERSION_LESS "3.20")
# CMake's built-in `FindGTest` module imported targets have different names
# in earlier CMake versions
add_library(GTest::gtest ALIAS GTest::GTest)
add_library(GTest::gtest_main ALIAS GTest::Main)
endif()

if (NOT TARGET GTest::gtest_main)
message("Target GTest:: stuff MISSING")
endif()
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(clib)
add_subdirectory(example)
11 changes: 0 additions & 11 deletions src/Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions src/clib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ add_library(Grackle_Grackle
phys_constants.h
utils.h

# C wrappers
c_wrappers/wrap_interpolators_g.c

# Fortran public headers
../include/grackle.def
../include/grackle_fortran_interface.def
Expand Down
44 changes: 0 additions & 44 deletions src/clib/Make.config.settings

This file was deleted.

112 changes: 0 additions & 112 deletions src/clib/Make.mach.darwin

This file was deleted.

85 changes: 0 additions & 85 deletions src/clib/Make.mach.linux-gnu

This file was deleted.

Loading