Skip to content

Commit 3e84932

Browse files
committed
[cmake] and insert configuration used during build into fclib.h
1 parent 9e50d2f commit 3e84932

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,19 @@ if(HARDCODE_NOT_HEADER_ONLY)
275275
"HARDCODE_NOT_HEADER_ONLY=${HARDCODE_NOT_HEADER_ONLY} "
276276
"and FCLIB_HEADER_ONLY=${FCLIB_HEADER_ONLY} are inconsistent.")
277277
endif()
278+
set(OPTDEFS FCLIB_NOT_HEADER_ONLY)
279+
if(FCLIB_WITH_MERIT_FUNCTIONS)
280+
set(OPTDEFS "${OPTDEFS};FCLIB_WITH_MERIT_FUNCTIONS")
281+
endif()
282+
set(DEFS)
283+
foreach(_D ${OPTDEFS})
284+
set(DEFS "${DEFS}\\n#ifndef ${_D}\\n#define ${_D}\\n#endif\\n")
285+
endforeach()
278286
add_custom_command(
279287
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fclib.h
280-
COMMAND sed -e '/@@/,/@@/d' ${CMAKE_CURRENT_SOURCE_DIR}/src/fclib.h
288+
COMMAND cat ${CMAKE_CURRENT_SOURCE_DIR}/src/fclib.h
289+
| sed 's,/\\*@ CONFIG @\\*/,${DEFS},'
290+
| sed '/@@/,/@@/d'
281291
| sed 's/FCLIB_STATIC //' >fclib.h
282292
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/fclib.h
283293
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}

src/fclib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
#define FCLIB_APICOMPILE
9292
#endif
9393

94+
/*@ CONFIG @*/
95+
9496
/*@@ Define FCLIB_NOT_HEADER_ONLY on the command-line when fclib is
9597
* compiled and installed as a library. The default is to use as a
9698
* header-only library. */

0 commit comments

Comments
 (0)