Skip to content

Commit 5d95ec1

Browse files
Clean up
1 parent d697b2b commit 5d95ec1

File tree

4 files changed

+78
-39
lines changed

4 files changed

+78
-39
lines changed

examples/CMakeLists.txt

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
# Include Dependencies
22
add_subdirectory(fortran_csv_module)
33
include(FetchContent)
4-
FetchContent_Declare(
5-
fplot
6-
GIT_REPOSITORY "https://github.com/jchristopherson/fplot"
7-
)
8-
FetchContent_MakeAvailable(fplot)
9-
set(fplot_LIBRARY fplot)
4+
find_package(ferror QUIET)
5+
find_package(fplot QUIET)
6+
if (NOT ferror_FOUND)
7+
FetchContent_Declare(
8+
ferror
9+
GIT_TAG "origin/master"
10+
GIT_REPOSITORY https://github.com/jchristopherson/ferror
11+
)
12+
FetchContent_MakeAvailable(ferror)
13+
set(ferror_LIBRARY ferror)
14+
else()
15+
set(ferror_LIBRARY ferror::ferror)
16+
endif()
17+
if (NOT fplot_FOUND)
18+
FetchContent_Declare(
19+
fplot
20+
GIT_TAG "origin/master"
21+
GIT_REPOSITORY https://github.com/jchristopherson/fplot
22+
)
23+
FetchContent_MakeAvailable(fplot)
24+
set(fplot_LIBRARY fplot)
25+
else()
26+
set(fplot_LIBRARY fplot::fplot)
27+
endif()
1028

1129
# Full Factorial Example
1230
add_executable(full_factorial_example full_factorial_example.f90)
@@ -32,47 +50,58 @@ configure_file(
3250
)
3351
add_executable(allan_example allan_example.f90)
3452
target_link_libraries(allan_example fstats)
35-
target_link_libraries(allan_example ${fplot_LIBRARY})
53+
target_link_libraries(allan_example ${fplot_LIBRARY} ${ferror_LIBRARY})
3654
target_link_libraries(allan_example ${fortran-csv-module_LIBRARY})
3755
target_include_directories(allan_example PUBLIC ${fortran-csv-module_INCLUDE_DIR})
3856

3957
# Box-Muller Example
4058
add_executable(box_muller_example box_muller_example.f90)
41-
target_link_libraries(box_muller_example fstats ${fplot_LIBRARY})
59+
target_link_libraries(box_muller_example fstats ${fplot_LIBRARY} ${ferror_LIBRARY})
4260

4361
# Rejection Sampling Example
4462
add_executable(rejection_sample_example rejection_sample_example.f90)
45-
target_link_libraries(rejection_sample_example fstats ${fplot_LIBRARY})
63+
target_link_libraries(rejection_sample_example fstats ${fplot_LIBRARY} ${ferror_LIBRARY})
4664

4765
# LOWESS Example
4866
add_executable(lowess_example lowess_example.f90)
49-
target_link_libraries(lowess_example fstats ${fplot_LIBRARY})
67+
target_link_libraries(lowess_example fstats ${fplot_LIBRARY} ${ferror_LIBRARY})
5068

5169
# Bootstrap Example
5270
add_executable(bootstrap_example bootstrap_example.f90)
53-
target_link_libraries(bootstrap_example fstats ${fplot_LIBRARY})
71+
target_link_libraries(bootstrap_example fstats ${fplot_LIBRARY} ${ferror_LIBRARY})
5472

5573
# MCMC Regression Example
5674
add_executable(mcmc_regression_example mcmc_regression_example.f90)
5775
target_link_libraries(mcmc_regression_example fstats)
58-
target_link_libraries(mcmc_regression_example ${fplot_LIBRARY})
76+
target_link_libraries(mcmc_regression_example ${fplot_LIBRARY} ${ferror_LIBRARY})
5977

6078
# MCMC Regression Example 2
6179
add_executable(mcmc_regression_example_2 mcmc_regression_example_2.f90)
6280
target_link_libraries(mcmc_regression_example_2 fstats)
63-
target_link_libraries(mcmc_regression_example_2 ${fplot_LIBRARY})
81+
target_link_libraries(mcmc_regression_example_2 ${fplot_LIBRARY} ${ferror_LIBRARY})
6482

6583
# MCMC Regression Example 3
6684
add_executable(mcmc_regression_example_3 mcmc_regression_example_3.f90)
6785
target_link_libraries(mcmc_regression_example_3 fstats)
68-
target_link_libraries(mcmc_regression_example_3 ${fplot_LIBRARY})
86+
target_link_libraries(mcmc_regression_example_3 ${fplot_LIBRARY} ${ferror_LIBRARY})
6987

7088
# Distribution Example
7189
add_executable(distribution_example distribution_example.f90)
7290
target_link_libraries(distribution_example fstats)
73-
target_link_libraries(distribution_example ${fplot_LIBRARY})
91+
target_link_libraries(distribution_example ${fplot_LIBRARY} ${ferror_LIBRARY})
7492

7593
# Interpolation Example
7694
add_executable(interpolation_example interpolation_example.f90)
7795
target_link_libraries(interpolation_example fstats)
78-
target_link_libraries(interpolation_example ${fplot_LIBRARY})
96+
target_link_libraries(interpolation_example ${fplot_LIBRARY} ${ferror_LIBRARY})
97+
98+
if (${BUILD_SHARED_LIBS} AND WIN32)
99+
add_custom_command(
100+
TARGET full_factorial_example
101+
POST_BUILD
102+
COMMAND ${CMAKE_COMMAND} -E copy
103+
$<TARGET_RUNTIME_DLLS:full_factorial_example>
104+
$<TARGET_FILE_DIR:full_factorial_example>
105+
COMMAND_EXPAND_LISTS
106+
)
107+
endif()

src/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@ target_link_libraries(
8484
${PROJECT_NAME}
8585
PUBLIC
8686
${FERROR_LIBRARIES}
87-
${LINALG_LIBRARIES}
8887
${COLLECTIONS_LIBRARIES}
8988
)
89+
target_link_libraries(
90+
${PROJECT_NAME}
91+
PRIVATE
92+
${LINALG_LIBRARIES}
93+
)
9094
if (OpenMP_Fortran_FOUND)
91-
target_link_libraries(${PROJECT_NAME} PUBLIC OpenMP::OpenMP_Fortran)
95+
target_link_libraries(${PROJECT_NAME} PRIVATE OpenMP::OpenMP_Fortran)
9296
target_compile_definitions(${PROJECT_NAME} PRIVATE USEOPENMP=1)
9397
endif()
9498

tests/CMakeLists.txt

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Dependencies
2-
add_subdirectory(fortran_test_helper)
3-
41
# Define the source files
52
set(fstats_test_sources
63
fstats_tests.f90
@@ -16,9 +13,11 @@ set(fstats_test_sources
1613
)
1714

1815
# Dependencies
16+
include(FetchContent)
1917
find_package(fortran_test_helper QUIET)
18+
find_package(ferror QUIET)
19+
find_package(linalg QUIET)
2020
if (NOT fortran_test_helper_FOUND)
21-
include(FetchContent)
2221
FetchContent_Declare(
2322
fortran_test_helper
2423
GIT_TAG "origin/main"
@@ -29,13 +28,37 @@ if (NOT fortran_test_helper_FOUND)
2928
else()
3029
set(FTH_LIBRARIES fortran_test_helper::fortran_test_helper)
3130
endif()
31+
if (NOT ferror_FOUND)
32+
FetchContent_Declare(
33+
ferror
34+
GIT_TAG "origin/master"
35+
GIT_REPOSITORY https://github.com/jchristopherson/ferror
36+
)
37+
FetchContent_MakeAvailable(ferror)
38+
set(FERROR_LIBRARIES ferror)
39+
else()
40+
set(FERROR_LIBRARIES ferror::ferror)
41+
endif()
42+
if (NOT linalg_FOUND)
43+
FetchContent_Declare(
44+
linalg
45+
GIT_TAG "origin/master"
46+
GIT_REPOSITORY https://github.com/jchristopherson/linalg
47+
)
48+
FetchContent_MakeAvailable(linalg)
49+
set(LINALG_LIBRARIES linalg)
50+
else()
51+
set(LINALG_LIBRARIES linalg::linalg)
52+
endif()
3253

3354
# Build the tests
3455
add_executable(fstats_tests ${fstats_test_sources})
3556
target_link_libraries(
3657
fstats_tests
3758
fstats
3859
${FTH_LIBRARIES}
60+
${FERROR_LIBRARIES}
61+
${LINALG_LIBRARIES}
3962
)
4063
add_test(
4164
NAME fstats_tests

tests/fortran_test_helper/CMakeLists.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)