From 40638924e022a8df8aa32154ee0bf14fe10dc4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Fri, 18 Aug 2023 15:39:32 +0200 Subject: [PATCH 1/2] Set -DBUILD_SHARED_LIBS=ON by default on scripts and CI/CD --- .github/workflows/build.yml | 2 +- build.bat | 52 ++++++++++++++++++------------------- build.sh | 2 +- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a75cf99..8ab524e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,7 @@ jobs: set(ENV{CC} ${{ matrix.config.cc }}) set(ENV{CXX} ${{ matrix.config.cxx }}) - run: mkdir build - - run: cmake -G "${{ matrix.config.generator }}" -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON -DSQLITECPP_RUN_CPPCHECK=OFF -DSQLITECPP_RUN_CPPLINT=OFF .. + - run: cmake -G "${{ matrix.config.generator }}" -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DBUILD_SHARED_LIBS=ON -DSQLITECPP_BUILD_TESTS=ON -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_RUN_CPPCHECK=OFF -DSQLITECPP_RUN_CPPLINT=OFF .. working-directory: build - run: cmake --build build --config ${{ matrix.config.build_type }} - run: ctest --verbose --output-on-failure --test-dir build diff --git a/build.bat b/build.bat index b8295963..aea7e94e 100644 --- a/build.bat +++ b/build.bat @@ -1,26 +1,26 @@ -@REM Copyright (c) 2012-2023 Sebastien Rombauts (sebastien.rombauts@gmail.com) -@REM -@REM Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt -@REM or copy at http://opensource.org/licenses/MIT) -mkdir build -cd build - -@REM Generate a Visual Studio solution for latest version found -REM -DPYTHON_EXECUTABLE=D:\workspace\Corvus\UnrealEngine\Engine\Binaries\ThirdParty\Python\Win64\python.exe -cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON -DSQLITECPP_RUN_CPPLINT=OFF .. -@if ERRORLEVEL 1 goto onError - -@REM Build default configuration (ie 'Debug') -cmake --build . -@if ERRORLEVEL 1 goto onError - -@REM Build and run tests -ctest --output-on-failure -@if ERRORLEVEL 1 goto onError - -@goto onSuccess - -:onError -@echo An error occured! -:onSuccess -@cd .. +@REM Copyright (c) 2012-2023 Sebastien Rombauts (sebastien.rombauts@gmail.com) +@REM +@REM Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt +@REM or copy at http://opensource.org/licenses/MIT) +mkdir build +cd build + +@REM Generate a Visual Studio solution for latest version found +REM -DPYTHON_EXECUTABLE=D:\workspace\Corvus\UnrealEngine\Engine\Binaries\ThirdParty\Python\Win64\python.exe +cmake -DBUILD_SHARED_LIBS=ON -DSQLITECPP_BUILD_TESTS=ON -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_RUN_CPPLINT=OFF .. +@if ERRORLEVEL 1 goto onError + +@REM Build default configuration (ie 'Debug') +cmake --build . +@if ERRORLEVEL 1 goto onError + +@REM Build and run tests +ctest --output-on-failure +@if ERRORLEVEL 1 goto onError + +@goto onSuccess + +:onError +@echo An error occured! +:onSuccess +@cd .. diff --git a/build.sh b/build.sh index df4cd1b8..67aa15c4 100755 --- a/build.sh +++ b/build.sh @@ -11,7 +11,7 @@ mkdir -p build cd build # Generate a Makefile for GCC (or Clang, depending on CC/CXX envvar) -cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_ASAN=ON -DSQLITECPP_USE_GCOV=OFF -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON .. +cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_ASAN=ON -DSQLITECPP_USE_GCOV=OFF -DBUILD_SHARED_LIBS=ON -DSQLITECPP_BUILD_TESTS=ON -DSQLITECPP_BUILD_EXAMPLES=ON .. # Build (ie 'make') cmake --build . From 3bdd13ae95119075c7e8e5e51379a8b9426d7636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Fri, 18 Aug 2023 16:09:35 +0200 Subject: [PATCH 2/2] set CMAKE_RUNTIME_OUTPUT_DIRECTORY so that executables and dlls share the bin/ directory --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fe97d18..345e7235 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,8 @@ option(SQLITECPP_BUILD_TESTS "Build and run tests." OFF) # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make it prominent option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + # Define useful variables to handle OS differences: if (WIN32) set(DEV_NULL "NUL") @@ -485,11 +487,11 @@ if (SQLITECPP_BUILD_TESTS) enable_testing() # does the tests pass? - add_test(UnitTests SQLiteCpp_tests) + add_test(UnitTests bin/SQLiteCpp_tests) if (SQLITECPP_BUILD_EXAMPLES) # does the example1 runs successfully? - add_test(Example1Run SQLiteCpp_example1) + add_test(Example1Run bin/SQLiteCpp_example1) endif (SQLITECPP_BUILD_EXAMPLES) else (SQLITECPP_BUILD_TESTS) message(STATUS "SQLITECPP_BUILD_TESTS OFF")