Skip to content

Commit 2b9b3b5

Browse files
authored
cmake: Set CMAKE_CURRENT_SOURCE_DIR to path of ${BZIP3_MAN}.in (#167)
If CMAKE_CURRENT_SOURCE_DIR is not specified to ${BZIP3_MAN}.in, it will refer to the current directory, which will result in an error if user builds with out-of-source builds. This sets CMAKE_CURRENT_SOURCE_DIR and supports out-of-source builds. ``` $ mkdir t && cd t && cmake .. -- The C compiler identification is GNU 14.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE CMake Error: File /home/iwamatsu/dev/bzip3/bz3grep.1 does not exist. CMake Error at CMakeLists.txt:152 (configure_file): configure_file Problem configuring file CMake Error: File /home/iwamatsu/dev/bzip3/bz3less.1 does not exist. CMake Error at CMakeLists.txt:152 (configure_file): configure_file Problem configuring file [...] ``` Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
1 parent 53984ef commit 2b9b3b5

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,17 @@ if(BZIP3_BUILD_APPS)
141141
bz3most.1
142142
bzip3.1)
143143
foreach(BZIP3_MAN ${BZIP3_MANS})
144-
if(EXISTS ${BZIP3_MAN}.in)
144+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${BZIP3_MAN}.in)
145145
string(TIMESTAMP MAN_DATE "%d %B %Y" UTC)
146146
set(TRANSFORMED_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
147147
set(MAN_DATE ${MAN_DATE})
148148
set(VERSION ${PROJECT_VERSION})
149-
configure_file(${BZIP3_MAN}.in ${CMAKE_CURRENT_BINARY_DIR}/${BZIP3_MAN}
149+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${BZIP3_MAN}.in
150+
${CMAKE_CURRENT_BINARY_DIR}/${BZIP3_MAN}
150151
@ONLY)
151152
else()
152-
configure_file(${BZIP3_MAN} ${CMAKE_CURRENT_BINARY_DIR}/${BZIP3_MAN}
153+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${BZIP3_MAN}
154+
${CMAKE_CURRENT_BINARY_DIR}/${BZIP3_MAN}
153155
COPYONLY)
154156
endif()
155157
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BZIP3_MAN}

0 commit comments

Comments
 (0)