From a0e27026d9d606233104eb1ea637a0612e39e1ce Mon Sep 17 00:00:00 2001 From: Denis <146707790+dnzbk@users.noreply.github.com> Date: Thu, 26 Dec 2024 14:45:43 +0300 Subject: [PATCH] Fix: build using CMake Ninja generator and the tests build failure with -DDISABLE_PARCHECK=yes (#481) - fixed build using CMake Ninja generator - fixed tests build failure with -DDISABLE_PARCHECK=yes --- cmake/boost.cmake | 23 +++++++++++++---------- cmake/par2-turbo.cmake | 31 ++++++++++++++++--------------- tests/postprocess/CMakeLists.txt | 15 ++++++++++----- 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/cmake/boost.cmake b/cmake/boost.cmake index 7d517368e..99af60764 100644 --- a/cmake/boost.cmake +++ b/cmake/boost.cmake @@ -1,19 +1,22 @@ -set(ROOT ${CMAKE_BINARY_DIR}/boost/) +set(BOOST_ROOT ${CMAKE_BINARY_DIR}/boost/src) +set(BOOST_LIBS ${BOOST_ROOT}/boost/stage/lib/libboost_json.a) ExternalProject_add( boost PREFIX boost URL https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.xz - TLS_VERIFY TRUE + TLS_VERIFY TRUE BUILD_IN_SOURCE TRUE - GIT_SHALLOW TRUE + GIT_SHALLOW TRUE + GIT_PROGRESS TRUE DOWNLOAD_EXTRACT_TIMESTAMP TRUE - CONFIGURE_COMMAND ${ROOT}src/boost/bootstrap.sh - --with-libraries=json - --prefix=${ROOT}build - BUILD_COMMAND ${ROOT}src/boost/b2 link=static - INSTALL_COMMAND ${ROOT}src/boost/b2 install + BUILD_BYPRODUCTS ${BOOST_LIBS} + CONFIGURE_COMMAND ${BOOST_ROOT}/boost/bootstrap.sh + --with-libraries=json + --prefix=${BOOST_ROOT}/build + BUILD_COMMAND ${BOOST_ROOT}/boost/b2 link=static + INSTALL_COMMAND "" ) -set(LIBS ${LIBS} ${ROOT}build/lib/libboost_json.a) -set(INCLUDES ${INCLUDES} ${ROOT}build/include/) +set(LIBS ${LIBS} ${BOOST_LIBS}) +set(INCLUDES ${INCLUDES} ${BOOST_ROOT}/boost) diff --git a/cmake/par2-turbo.cmake b/cmake/par2-turbo.cmake index 7ef53d8b4..ed483573c 100644 --- a/cmake/par2-turbo.cmake +++ b/cmake/par2-turbo.cmake @@ -1,4 +1,17 @@ set(PAR2_ROOT ${CMAKE_BINARY_DIR}/par2-turbo/src) +if(WIN32) + set(PAR2_LIBS + ${PAR2_ROOT}/par2-turbo-build/${CMAKE_BUILD_TYPE}/par2-turbo.lib + ${PAR2_ROOT}/par2-turbo-build/${CMAKE_BUILD_TYPE}/gf16.lib + ${PAR2_ROOT}/par2-turbo-build/${CMAKE_BUILD_TYPE}/hasher.lib + ) +else() + set(PAR2_LIBS + ${PAR2_ROOT}/par2-turbo-build/libpar2-turbo.a + ${PAR2_ROOT}/par2-turbo-build/libgf16.a + ${PAR2_ROOT}/par2-turbo-build/libhasher.a + ) +endif() add_compile_definitions(HAVE_CONFIG_H PARPAR_ENABLE_HASHER_MD5CRC) @@ -33,22 +46,10 @@ ExternalProject_add( GIT_SHALLOW TRUE GIT_PROGRESS TRUE DOWNLOAD_EXTRACT_TIMESTAMP TRUE - CMAKE_ARGS ${CMAKE_ARGS} + BUILD_BYPRODUCTS ${PAR2_LIBS} + CMAKE_ARGS ${CMAKE_ARGS} INSTALL_COMMAND "" ) -if(WIN32) - set(LIBS ${LIBS} - ${PAR2_ROOT}/par2-turbo-build/${CMAKE_BUILD_TYPE}/par2-turbo.lib - ${PAR2_ROOT}/par2-turbo-build/${CMAKE_BUILD_TYPE}/gf16.lib - ${PAR2_ROOT}/par2-turbo-build/${CMAKE_BUILD_TYPE}/hasher.lib - ) -else() - set(LIBS ${LIBS} - ${PAR2_ROOT}/par2-turbo-build/libpar2-turbo.a - ${PAR2_ROOT}/par2-turbo-build/libgf16.a - ${PAR2_ROOT}/par2-turbo-build/libhasher.a - ) -endif() - +set(LIBS ${LIBS} ${PAR2_LIBS}) set(INCLUDES ${INCLUDES} ${PAR2_ROOT}/par2-turbo/include) diff --git a/tests/postprocess/CMakeLists.txt b/tests/postprocess/CMakeLists.txt index 98886cc0e..8b02a7df3 100644 --- a/tests/postprocess/CMakeLists.txt +++ b/tests/postprocess/CMakeLists.txt @@ -2,16 +2,11 @@ set(PostprocessTestsSrc main.cpp # DirectUnpackTest.cpp # DupeMatcherTest.cpp - ParCheckerTest.cpp - ParRenamerTest.cpp RarReaderTest.cpp RarRenamerTest.cpp ../suite/TestUtil.cpp # ${CMAKE_SOURCE_DIR}/daemon/postprocess/DirectUnpack.cpp # ${CMAKE_SOURCE_DIR}/daemon/postprocess/DupeMatcher.cpp - ${CMAKE_SOURCE_DIR}/daemon/postprocess/ParChecker.cpp - ${CMAKE_SOURCE_DIR}/daemon/postprocess/ParParser.cpp - ${CMAKE_SOURCE_DIR}/daemon/postprocess/ParRenamer.cpp ${CMAKE_SOURCE_DIR}/daemon/postprocess/RarReader.cpp ${CMAKE_SOURCE_DIR}/daemon/postprocess/RarRenamer.cpp ${CMAKE_SOURCE_DIR}/daemon/main/Options.cpp @@ -25,6 +20,16 @@ set(PostprocessTestsSrc ${CMAKE_SOURCE_DIR}/daemon/queue/DiskState.cpp ) +if(NOT DISABLE_PARCHECK) + set(PostprocessTestsSrc ${PostprocessTestsSrc} + ParCheckerTest.cpp + ParRenamerTest.cpp + ${CMAKE_SOURCE_DIR}/daemon/postprocess/ParChecker.cpp + ${CMAKE_SOURCE_DIR}/daemon/postprocess/ParParser.cpp + ${CMAKE_SOURCE_DIR}/daemon/postprocess/ParRenamer.cpp + ) +endif() + if(WIN32) set(PostprocessTestsSrc ${PostprocessTestsSrc} ${CMAKE_SOURCE_DIR}/daemon/util/Utf8.cpp) endif()