From 79854b45b5f737a701fb84a33ad3af3b740a1d2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Tabin?= Date: Mon, 30 Mar 2020 00:35:46 +0200 Subject: [PATCH 1/2] Fixes install paths after CMake modifications --- compile.bat | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compile.bat b/compile.bat index 8fd7de6..2f74310 100644 --- a/compile.bat +++ b/compile.bat @@ -1,6 +1,7 @@ @echo off +SET root=%cd% SET zlib=lib\zlib-1.2.11 SET libzip=lib\libzip-1.6.1 @@ -13,7 +14,7 @@ echo Compiling zlib... cd "%zlib%" mkdir build cd "build" -cmake .. -DCMAKE_INSTALL_PREFIX="../../install" +cmake .. -DCMAKE_INSTALL_PREFIX="%root%/lib/install" if %ERRORLEVEL% GEQ 1 goto error_zlib cmake --build . --config Debug --target install if %ERRORLEVEL% GEQ 1 goto error_zlib @@ -27,7 +28,7 @@ echo Compiling libzip... cd "%libzip%" mkdir build cd "build" -cmake .. -DCMAKE_INSTALL_PREFIX="../../install" -DCMAKE_PREFIX_PATH="../../install" -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF -DENABLE_WINDOWS_CRYPTO=ON -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOC=OFF +cmake .. -DCMAKE_INSTALL_PREFIX="%root%/lib/install" -DCMAKE_PREFIX_PATH="%root%/lib/install" -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF -DENABLE_WINDOWS_CRYPTO=ON -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOC=OFF if %ERRORLEVEL% GEQ 1 goto error_libzip cmake --build . --config Debug --target install if %ERRORLEVEL% GEQ 1 goto error_libzip @@ -37,14 +38,14 @@ cd "..\..\.." :prepare_libzippp echo Compiling lizippp... +rmdir /q /s "build" mkdir build cd "build" -cmake .. -DCMAKE_PREFIX_PATH="../lib/install" +cmake .. -DCMAKE_PREFIX_PATH="%root%/lib/install" if %ERRORLEVEL% GEQ 1 goto error_libzippp cd ".." :compile_libzippp -if exist "build/libzippp_static.lib" goto package_libzippp cmake --build build --config Debug if %ERRORLEVEL% GEQ 1 goto error_libzippp cmake --build build --config Release @@ -104,4 +105,5 @@ echo [ERROR] Unable to compile libzippp goto end :end +cd %root% cmd From 7bbe52fc6b4a3881ae5bfbdfaccba8f4ba9855d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Tabin?= Date: Mon, 30 Mar 2020 01:16:15 +0200 Subject: [PATCH 2/2] Fixes static/shared libraries output names --- CMakeLists.txt | 8 +++++ compile.bat | 91 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 63 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 610398f..d2c103d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,8 @@ set_target_properties(libzippp PROPERTIES PREFIX "") # Avoid duplicate "lib" pre target_link_libraries(libzippp PRIVATE libzip::libzip) if (BUILD_SHARED_LIBS) target_compile_definitions(libzippp PRIVATE LIBZIPPP_EXPORTS) +else() + set_target_properties(libzippp PROPERTIES OUTPUT_NAME "libzippp_static") endif() export(TARGETS libzippp NAMESPACE libzippp:: FILE ${PROJECT_BINARY_DIR}/libzippp-target.cmake) @@ -37,6 +39,12 @@ if(LIBZIPPP_BUILD_TESTS) add_executable(libzippp_test "tests/tests.cpp") target_link_libraries(libzippp_test PRIVATE libzippp) add_test(NAME libzippp_tests COMMAND libzippp_test) + + if (BUILD_SHARED_LIBS) + set_target_properties(libzippp_test PROPERTIES OUTPUT_NAME "libzippp_shared_test") + else() + set_target_properties(libzippp_test PROPERTIES OUTPUT_NAME "libzippp_static_test") + endif() endif() if(LIBZIPPP_INSTALL) diff --git a/compile.bat b/compile.bat index 2f74310..6d50858 100644 --- a/compile.bat +++ b/compile.bat @@ -10,25 +10,29 @@ if not exist "%libzip%" goto error_libzip_not_found :compile_zlib if exist "%zlib%\build" goto compile_libzip +echo ============================= echo Compiling zlib... +echo ============================= cd "%zlib%" mkdir build cd "build" -cmake .. -DCMAKE_INSTALL_PREFIX="%root%/lib/install" +cmake ".." -DCMAKE_INSTALL_PREFIX="%root%/lib/install" if %ERRORLEVEL% GEQ 1 goto error_zlib -cmake --build . --config Debug --target install +cmake --build "." --config Debug --target install if %ERRORLEVEL% GEQ 1 goto error_zlib -cmake --build . --config Release --target install +cmake --build "." --config Release --target install if %ERRORLEVEL% GEQ 1 goto error_zlib cd "..\..\.." :compile_libzip -if exist "%libzip%\build" goto prepare_libzippp +if exist "%libzip%\build" goto compile_libzippp +echo ============================= echo Compiling libzip... +echo ============================= cd "%libzip%" -mkdir build +mkdir "build" cd "build" -cmake .. -DCMAKE_INSTALL_PREFIX="%root%/lib/install" -DCMAKE_PREFIX_PATH="%root%/lib/install" -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF -DENABLE_WINDOWS_CRYPTO=ON -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOC=OFF +cmake ".." -DCMAKE_INSTALL_PREFIX="%root%/lib/install" -DCMAKE_PREFIX_PATH="%root%/lib/install" -DENABLE_COMMONCRYPTO=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF -DENABLE_WINDOWS_CRYPTO=ON -DBUILD_TOOLS=OFF -DBUILD_REGRESS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_DOC=OFF if %ERRORLEVEL% GEQ 1 goto error_libzip cmake --build . --config Debug --target install if %ERRORLEVEL% GEQ 1 goto error_libzip @@ -36,45 +40,60 @@ cmake --build . --config Release --target install if %ERRORLEVEL% GEQ 1 goto error_libzip cd "..\..\.." -:prepare_libzippp -echo Compiling lizippp... +:compile_libzippp +rmdir /q /s "dist" +mkdir "dist" +cd "dist" +mkdir "release" +copy "..\%zlib%\build\Release\zlib.dll" release +copy "..\%libzip%\build\lib\Release\zip.dll" release +copy "..\src\libzippp.h" release + +mkdir "debug" +copy "..\%zlib%\build\Debug\zlibd.dll" debug +copy "..\%libzip%\build\lib\Debug\zip.dll" debug +copy "..\src\libzippp.h" debug +cd ".." + +echo ============================= +echo Compiling (shared) lizippp... +echo ============================= rmdir /q /s "build" -mkdir build +mkdir "build" cd "build" -cmake .. -DCMAKE_PREFIX_PATH="%root%/lib/install" +cmake .. -DCMAKE_PREFIX_PATH="%root%/lib/install" -DBUILD_SHARED_LIBS=ON if %ERRORLEVEL% GEQ 1 goto error_libzippp cd ".." - -:compile_libzippp cmake --build build --config Debug if %ERRORLEVEL% GEQ 1 goto error_libzippp cmake --build build --config Release if %ERRORLEVEL% GEQ 1 goto error_libzippp + +copy "build\Release\libzippp_shared_test.exe" "dist/release" +copy "build\Release\libzippp.dll" "dist/release" +copy "build\Release\libzippp.lib" "dist/release" +copy "build\Debug\libzippp_shared_test.exe" "dist/debug" +copy "build\Debug\libzippp.dll" "dist/debug" +copy "build\Debug\libzippp.lib" "dist/debug" + +echo ============================= +echo Compiling (static) lizippp... +echo ============================= +rmdir /q /s "build" +mkdir "build" +cd "build" +cmake .. -DCMAKE_PREFIX_PATH="%root%/lib/install" -DBUILD_SHARED_LIBS=OFF +if %ERRORLEVEL% GEQ 1 goto error_libzippp cd ".." +cmake --build build --config Debug +if %ERRORLEVEL% GEQ 1 goto error_libzippp +cmake --build build --config Release +if %ERRORLEVEL% GEQ 1 goto error_libzippp -:package_libzippp -if exist "dist\libzippp_static.lib" goto end -mkdir "dist" -cd "dist" -mkdir release -copy ..\src\libzippp.h release -copy ..\build\Release\libzippp_shared_test.exe release -copy ..\build\Release\libzippp_static_test.exe release -copy ..\build\Release\libzippp.dll release -copy ..\build\Release\libzippp.lib release -copy ..\build\Release\libzippp_static.lib release -copy ..\%zlib%\build\Release\zlib.dll release -copy ..\%libzip%\build\lib\Release\zip.dll release -mkdir debug -copy ..\src\libzippp.h debug -copy ..\build\Debug\libzippp_shared_test.exe debug -copy ..\build\Debug\libzippp_static_test.exe debug -copy ..\build\Debug\libzippp.dll debug -copy ..\build\Debug\libzippp.lib debug -copy ..\build\Debug\libzippp_static.lib debug -copy ..\%zlib%\build\Debug\zlibd.dll debug -copy ..\%libzip%\build\lib\Debug\zip.dll debug -cd .. +copy "build\Release\libzippp_static_test.exe" "dist/release" +copy "build\Release\libzippp_static.lib" "dist/release" +copy "build\Debug\libzippp_static_test.exe" "dist/debug" +copy "build\Debug\libzippp_static.lib" "dist/debug" goto end @@ -105,5 +124,5 @@ echo [ERROR] Unable to compile libzippp goto end :end -cd %root% +cd "%root%" cmd