Skip to content

Commit

Permalink
Merge pull request #58 from ctabin/compile-bat-paths
Browse files Browse the repository at this point in the history
Fixes install paths after CMake modifications
  • Loading branch information
ctabin authored Mar 29, 2020
2 parents 876dd6c + 7bbe52f commit ee6849d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 36 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
93 changes: 57 additions & 36 deletions compile.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

@echo off

SET root=%cd%
SET zlib=lib\zlib-1.2.11
SET libzip=lib\libzip-1.6.1

Expand All @@ -9,71 +10,90 @@ 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="../../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="../../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
cmake --build . --config Release --target install
if %ERRORLEVEL% GEQ 1 goto error_libzip
cd "..\..\.."

:prepare_libzippp
echo Compiling lizippp...
mkdir build
: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"
cd "build"
cmake .. -DCMAKE_PREFIX_PATH="../lib/install"
cmake .. -DCMAKE_PREFIX_PATH="%root%/lib/install" -DBUILD_SHARED_LIBS=ON
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
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

Expand Down Expand Up @@ -104,4 +124,5 @@ echo [ERROR] Unable to compile libzippp
goto end

:end
cd "%root%"
cmd

0 comments on commit ee6849d

Please sign in to comment.