Skip to content

Commit ca2f25f

Browse files
tobiololauft
authored andcommitted
Do not reconfigure cmake.h if libshared is used as CMake subdirectory
Signed-off-by: Tobias Predel <[email protected]>
1 parent 97dab12 commit ca2f25f

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

CMakeLists.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,18 @@ set (PACKAGE_TARNAME "${PACKAGE}")
2121
set (PACKAGE_VERSION "${VERSION}")
2222
set (PACKAGE_STRING "${PACKAGE} ${VERSION}")
2323

24-
check_function_exists(strlcpy HAVE_STRLCPY)
25-
check_function_exists(timegm HAVE_TIMEGM)
26-
27-
message ("-- Configuring cmake.h")
28-
configure_file (
29-
${CMAKE_SOURCE_DIR}/cmake.h.in
30-
${CMAKE_SOURCE_DIR}/cmake.h)
24+
if (PROJECT_IS_TOP_LEVEL)
25+
# cmake.h should only be configured if libshared is not used as a CMake subdirectory.
26+
# If libshared is a CMake subdirectory, the top-level project already configures
27+
# cmake.h by itself.
28+
check_function_exists(strlcpy HAVE_STRLCPY)
29+
check_function_exists(timegm HAVE_TIMEGM)
30+
31+
message ("-- Configuring cmake.h")
32+
configure_file (
33+
${CMAKE_SOURCE_DIR}/cmake.h.in
34+
${CMAKE_SOURCE_DIR}/cmake.h)
35+
endif (PROJECT_IS_TOP_LEVEL)
3136

3237
add_subdirectory (src)
3338
if (EXISTS ${CMAKE_SOURCE_DIR}/test)

0 commit comments

Comments
 (0)