Skip to content

Commit aae14c2

Browse files
committed
fix: replace GLOB with explicit file lists in CMakeLists
Replace file(GLOB) with explicit source lists in src/cpp, tests/cpp, and examples/cpp CMakeLists.txt to avoid stale builds when files are added or renamed. Resolves #203.
1 parent b464100 commit aae14c2

3 files changed

Lines changed: 55 additions & 10 deletions

File tree

examples/cpp/CMakeLists.txt

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,44 @@
11
# examples_C++ Configuration
22
include_directories("${CMAKE_SOURCE_DIR}/src/cpp")
33

4-
# Find all .cpp files in the examples directory
5-
file(GLOB EXAMPLE_SOURCES *.cpp)
4+
set(EXAMPLE_SOURCES
5+
backward_euler.cpp
6+
burgers1D.cpp
7+
convection_diffusion3D.cpp
8+
elliptic1D.cpp
9+
elliptic1DHomogeneousDirichlet.cpp
10+
elliptic1DLeftNeumannRightDirichlet.cpp
11+
elliptic1DLeftNeumannRightNeumann.cpp
12+
elliptic1DNonHomogeneousDirichlet.cpp
13+
elliptic2D.cpp
14+
elliptic2D_x_dirichlet_y_dirichlet.cpp
15+
elliptic3D.cpp
16+
hyperbolic1D_upwind.cpp
17+
lock_exchange.cpp
18+
maxwell1D.cpp
19+
parabolic1D.cpp
20+
poisson2D.cpp
21+
poisson_2D_dirichlet.cpp
22+
RK2.cpp
23+
schrodinger1D.cpp
24+
schrodinger2D.cpp
25+
sturmLiouvilleBessel.cpp
26+
sturmLiouvilleChebyshev.cpp
27+
sturmLiouvilleHelmholtzDirichletDirichlet.cpp
28+
sturmLiouvilleHelmholtzDirichletRobin.cpp
29+
sturmLiouvilleHermite.cpp
30+
sturmLiouvilleLaguerre.cpp
31+
sturmLiouvilleLegendre.cpp
32+
transport1D.cpp
33+
wave1d_case2.cpp
34+
wave1d.cpp
35+
wave2d_case2.cpp
36+
wave2d.cpp
37+
)
638

739
# Create executables for each source file
840
foreach(EXAMPLE_SOURCE ${EXAMPLE_SOURCES})
941
get_filename_component(EXAMPLE_NAME ${EXAMPLE_SOURCE} NAME_WE)
1042
add_executable(${EXAMPLE_NAME} ${EXAMPLE_SOURCE})
1143
target_link_libraries(${EXAMPLE_NAME} PUBLIC mole_C++ ${LINK_LIBS})
12-
endforeach()
44+
endforeach()

src/cpp/CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# mole_C++ Library Configuration
22

3-
file(GLOB SOURCES *.cpp)
4-
add_library(mole_C++ ${SOURCES})
3+
add_library(mole_C++
4+
addscalarbc.cpp
5+
divergence.cpp
6+
gradient.cpp
7+
interpol.cpp
8+
laplacian.cpp
9+
mixedbc.cpp
10+
robinbc.cpp
11+
utils.cpp
12+
)
513
target_include_directories(mole_C++ PUBLIC ${ARMADILLO_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${OpenBLAS_INCLUDE_DIRS} ${SUPERLU_INCLUDE_DIR})
614
target_link_libraries(mole_C++ PUBLIC ${LINK_LIBS})
715

@@ -11,4 +19,4 @@ install(TARGETS mole_C++ DESTINATION lib)
1119

1220

1321
# ${CMAKE_INSTALL_PREFIX}/lib for custom installation path.
14-
# ${CMAKE_BINARY_DIR}/install for cmake build directory installation
22+
# ${CMAKE_BINARY_DIR}/install for cmake build directory installation

tests/cpp/CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,14 @@ FetchContent_Declare(
1313
# Set up the fetched content
1414
FetchContent_MakeAvailable(googletest)
1515

16-
# Find all test*.cpp files
17-
file(GLOB TEST_SOURCES test*.cpp)
16+
set(TEST_SOURCES
17+
test1.cpp
18+
test2.cpp
19+
test3.cpp
20+
test4.cpp
21+
test5.cpp
22+
test_addscalarbc.cpp
23+
)
1824

1925
set(TEST_EXECUTABLES "")
2026

@@ -38,5 +44,4 @@ endforeach()
3844
add_custom_target(run_tests
3945
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
4046
DEPENDS ${TEST_EXECUTABLES}
41-
)
42-
47+
)

0 commit comments

Comments
 (0)