Skip to content

Commit 6929c13

Browse files
committed
add C89 support for CMake
Signed-off-by: Steffen Jaeckel <[email protected]>
1 parent f3b8879 commit 6929c13

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,17 @@ target_link_options(${PROJECT_NAME} BEFORE PRIVATE
103103
${LTM_LD_FLAGS}
104104
)
105105

106+
set(PUBLIC_HEADERS tommath.h)
107+
set(C89 False CACHE BOOL "(Usually maintained automatically) Enable when the library is in c89 mode to package the correct header files on install")
108+
if(C89)
109+
list(APPEND PUBLIC_HEADERS tommath_c89.h)
110+
endif()
111+
106112
set_target_properties(${PROJECT_NAME} PROPERTIES
107113
OUTPUT_NAME tommath
108114
VERSION ${PROJECT_VERSION}
109115
SOVERSION ${PROJECT_VERSION_MAJOR}
110-
PUBLIC_HEADER tommath.h
116+
PUBLIC_HEADER "${PUBLIC_HEADERS}"
111117
)
112118

113119
option(COMPILE_LTO "Build with LTO enabled")

makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ c89:
173173
-e 's/uint\([0-9][0-9]*\)_t/mp_u\1/g' \
174174
-e 's/int\([0-9][0-9]*\)_t/mp_i\1/g' \
175175
-e 's/__func__/MP_FUNCTION_NAME/g' \
176-
*.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c
176+
-e 's/set(C89 False/set(C89 True/g' \
177+
*.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c CMakeLists.txt
177178

178179
c99:
179180
@echo "Applying substitutions for c99 compatibility..."
@@ -196,7 +197,8 @@ c99:
196197
-e 's/mp_u\([0-9][0-9]*\)/uint\1_t/g' \
197198
-e 's/mp_i\([0-9][0-9]*\)/int\1_t/g' \
198199
-e 's/MP_FUNCTION_NAME/__func__/g' \
199-
*.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c
200+
-e 's/set(C89 True/set(C89 False/g' \
201+
*.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c CMakeLists.txt
200202

201203
astyle:
202204
@echo " * run astyle on all sources"

0 commit comments

Comments
 (0)