add C89 support for CMake Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 63b62ac..525ba1c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -103,11 +103,17 @@ target_link_options(${PROJECT_NAME} BEFORE PRIVATE
${LTM_LD_FLAGS}
)
+set(PUBLIC_HEADERS tommath.h)
+set(C89 False CACHE BOOL "(Usually maintained automatically) Enable when the library is in c89 mode to package the correct header files on install")
+if(C89)
+ list(APPEND PUBLIC_HEADERS tommath_c89.h)
+endif()
+
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME tommath
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
- PUBLIC_HEADER tommath.h
+ PUBLIC_HEADER "${PUBLIC_HEADERS}"
)
option(COMPILE_LTO "Build with LTO enabled")
diff --git a/makefile b/makefile
index 7fa04d2..7fe933f 100644
--- a/makefile
+++ b/makefile
@@ -173,7 +173,8 @@ c89:
-e 's/uint\([0-9][0-9]*\)_t/mp_u\1/g' \
-e 's/int\([0-9][0-9]*\)_t/mp_i\1/g' \
-e 's/__func__/MP_FUNCTION_NAME/g' \
- *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c
+ -e 's/set(C89 False/set(C89 True/g' \
+ *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c CMakeLists.txt
c99:
@echo "Applying substitutions for c99 compatibility..."
@@ -196,7 +197,8 @@ c99:
-e 's/mp_u\([0-9][0-9]*\)/uint\1_t/g' \
-e 's/mp_i\([0-9][0-9]*\)/int\1_t/g' \
-e 's/MP_FUNCTION_NAME/__func__/g' \
- *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c
+ -e 's/set(C89 True/set(C89 False/g' \
+ *.c tommath.h tommath_private.h demo/*.c demo/*.h etc/*.c CMakeLists.txt
astyle:
@echo " * run astyle on all sources"