Skip to content

Commit

Permalink
CMakeLists.txt: Fix add_subdirectory build
Browse files Browse the repository at this point in the history
When zlib is built via an add_subdirectory() call, ${CMAKE_SOURCE_DIR}
is the source directory of the parent project. Use
${CMAKE_CURRENT_SOURCE_DIR} instead to refer to the source directory of
the zlib project.

Remove a redundant include_directories(${CMAKE_CURRENT_SOURCE_DIR}) call
in the if(MSVC) block.

Note: This pull request is essentially the same as
madler#471. The only difference is to use
MAKE_CURRENT_SOURCE_DIR instead of PROJECT_SOURCE_DIR.
  • Loading branch information
wantehchang committed May 25, 2023
1 parent 04f42ce commit 9b2dfe3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()

if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
Expand All @@ -80,7 +79,7 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})


#============================================================================
Expand Down

0 comments on commit 9b2dfe3

Please sign in to comment.