Skip to content

Commit 38576ca

Browse files
authored
Merge pull request #1088 from jvdp1/simpli_cpp
Simplification of CPP macros for modularizing stdlib
2 parents 211ea0b + fc5667a commit 38576ca

File tree

12 files changed

+47
-45
lines changed

12 files changed

+47
-45
lines changed

.github/workflows/ci_modular.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ jobs:
5656
-DCMAKE_MAXIMUM_RANK:String=4
5757
-DCMAKE_INSTALL_PREFIX=$PWD/_dist
5858
-DFIND_BLAS:STRING=FALSE
59-
-DSTDLIB_NO_BITSET:STRING=${{ matrix.with_bitset }}
60-
-DSTDLIB_NO_STATS:STRING=${{ matrix.with_stats }}
59+
-DSTDLIB_BITSET:STRING=${{ matrix.with_bitset }}
60+
-DSTDLIB_STATS:STRING=${{ matrix.with_stats }}
6161
-S . -B ${{ env.BUILD_DIR }}
6262
6363
- name: Build and compile

CMakeLists.txt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,24 @@ if(NOT DEFINED CMAKE_MAXIMUM_RANK)
4949
set(CMAKE_MAXIMUM_RANK 4 CACHE STRING "Maximum array rank for generated procedures")
5050
endif()
5151

52-
option(STDLIB_NO_BITSET "Does not compile STDLIB BITSET" OFF)
52+
option(STDLIB_BITSET "Compile STDLIB BITSET" ON)
5353

54-
if(STDLIB_NO_BITSET)
54+
if(STDLIB_BITSET)
55+
message(STATUS "Enable stdlib bitset module")
56+
add_compile_definitions(STDLIB_BITSET=1)
57+
else()
5558
message(STATUS "Disable stdlib bitset module")
56-
add_compile_definitions(STDLIB_NO_BITSET)
59+
add_compile_definitions(STDLIB_BITSET=0)
5760
endif()
5861

59-
option(STDLIB_NO_STATS "Does not compile STDLIB STATS" OFF)
62+
option(STDLIB_STATS "Compile STDLIB STATS" ON)
6063

61-
if(STDLIB_NO_STATS)
64+
if(STDLIB_STATS)
65+
message(STATUS "Enable stdlib stats module")
66+
add_compile_definitions(STDLIB_STATS=1)
67+
else()
6268
message(STATUS "Disable stdlib stats module")
63-
add_compile_definitions(STDLIB_NO_STATS)
69+
add_compile_definitions(STDLIB_STATS=0)
6470
endif()
6571

6672
option(FIND_BLAS "Find external BLAS and LAPACK" ON)

example/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ endmacro(ADD_EXAMPLEPP)
1919
add_subdirectory(ansi)
2020
add_subdirectory(array)
2121
add_subdirectory(ascii)
22-
if (NOT STDLIB_NO_BITSET)
22+
if (STDLIB_BITSET)
2323
add_subdirectory(bitsets)
2424
endif()
2525
add_subdirectory(constants)
@@ -38,7 +38,7 @@ add_subdirectory(selection)
3838
add_subdirectory(sorting)
3939
add_subdirectory(specialfunctions_gamma)
4040
add_subdirectory(specialmatrices)
41-
if (NOT STDLIB_NO_STATS)
41+
if (STDLIB_STATS)
4242
add_subdirectory(stats)
4343
add_subdirectory(stats_distribution_exponential)
4444
add_subdirectory(stats_distribution_normal)

example/sorting/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ ADD_EXAMPLE(sort)
33
ADD_EXAMPLE(sort_adjoint)
44
ADD_EXAMPLE(sort_index)
55
ADD_EXAMPLE(radix_sort)
6-
if (NOT STDLIB_NO_BITSET)
6+
if (STDLIB_BITSET)
77
ADD_EXAMPLE(sort_bitset)
88
endif()

include/common.fypp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ $:"s" if cmplx=="c" else "d" if cmplx=="z" else "x" if cmplx=="y" else "q" if cm
151151
#:set BITSET_INIT = ["" for k in BITSET_KINDS]
152152

153153
#! Bitset CPP directive to be considered during templating
154-
#:set BITSET_CPPS = ["STDLIB_BITSET == 1" for k in BITSET_KINDS]
154+
#:set BITSET_CPPS = ["STDLIB_BITSET" for k in BITSET_KINDS]
155155

156156
#! Collected (kind, type) tuples for bitset types
157157
#:set BITSET_KINDS_TYPES = list(zip(BITSET_KINDS, BITSET_TYPES, BITSET_INIT, BITSET_CPPS))

include/macros.inc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11

22
!Default: compile the bitset module
3-
#ifdef STDLIB_NO_BITSET
4-
#define STDLIB_BITSET 0
5-
#else
3+
#if !defined STDLIB_BITSET
64
#define STDLIB_BITSET 1
75
#endif
86

97
!Default: compile the stats module
10-
#ifdef STDLIB_NO_STATS
11-
#define STDLIB_STATS 0
12-
#else
8+
#if !defined STDLIB_STATS
139
#define STDLIB_STATS 1
1410
#endif

src/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
if (NOT STDLIB_NO_BITSET)
1+
if (STDLIB_BITSET)
22
add_subdirectory(bitsets)
33
endif()
44
add_subdirectory(blas)
55
add_subdirectory(lapack)
66
add_subdirectory(lapack_extended)
7-
if (NOT STDLIB_NO_STATS)
7+
if (STDLIB_STATS)
88
add_subdirectory(stats)
99
endif()
1010

@@ -115,6 +115,6 @@ set(f90Files
115115
configure_stdlib_target(${PROJECT_NAME} f90Files fppFiles cppFiles)
116116

117117
target_link_libraries(${PROJECT_NAME} PUBLIC
118-
$<$<NOT:$<BOOL:${STDLIB_NO_BITSET}>>:bitsets>
119-
$<$<NOT:$<BOOL:${STDLIB_NO_STATS}>>:stats>
120-
blas lapack lapack_extended)
118+
$<$<BOOL:${STDLIB_BITSET}>:bitsets>
119+
$<$<BOOL:${STDLIB_STATS}>:stats>
120+
blas lapack lapack_extended)

src/stdlib_math.fypp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
module stdlib_math
66
use stdlib_kinds, only: int8, int16, int32, int64, sp, dp, xdp, qp
77
use stdlib_optval, only: optval
8-
#if STDLIB_BITSET == 1
8+
#if STDLIB_BITSET
99
use stdlib_bitsets, only: bitset_64, bitset_large
1010
#endif
1111

src/stdlib_sorting.fypp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ module stdlib_sorting
135135
use stdlib_string_type, only: string_type, assignment(=), operator(>), &
136136
operator(>=), operator(<), operator(<=)
137137

138-
#if STDLIB_BITSET == 1
138+
#if STDLIB_BITSET
139139
use stdlib_bitsets, only: bitset_64, bitset_large, &
140140
assignment(=), operator(>), operator(>=), operator(<), operator(<=)
141141
#endif

test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ endmacro(ADDTESTPP)
2929

3030
add_subdirectory(array)
3131
add_subdirectory(ascii)
32-
if (NOT STDLIB_NO_BITSET)
32+
if (STDLIB_BITSET)
3333
add_subdirectory(bitsets)
3434
endif()
3535
add_subdirectory(constants)
@@ -44,7 +44,7 @@ add_subdirectory(optval)
4444
add_subdirectory(selection)
4545
add_subdirectory(sorting)
4646
add_subdirectory(specialfunctions)
47-
if (NOT STDLIB_NO_STATS)
47+
if (STDLIB_STATS)
4848
add_subdirectory(stats)
4949
endif()
5050
add_subdirectory(string)

0 commit comments

Comments
 (0)