From 03756b042975286b0faefcdeb63cbb2aa390645f Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 22 Oct 2023 12:58:19 +0200 Subject: [PATCH] build: write binaries to bin folder --- .gitignore | 3 ++- .pre-commit-config.yaml | 2 +- CMakeLists.txt | 6 ++++++ bootstrap.sh | 2 +- build.sh | 2 +- test.sh | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 65af97a..be9452d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -/build +/.build /.cache +/bin diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95c4d1e..cc8b389 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: hooks: - id: clang-format - id: clang-tidy - args: [-p=build] + args: [-p=.build] - repo: https://github.com/cheshirekow/cmake-format-precommit rev: v0.6.13 diff --git a/CMakeLists.txt b/CMakeLists.txt index 31c0d68..88fc91b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,12 @@ target_include_directories( target_link_libraries(book_exercises PRIVATE chapter_02) +set_target_properties( + book_exercises + PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin" + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin" + RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin") + if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) add_subdirectory(tests) endif() diff --git a/bootstrap.sh b/bootstrap.sh index abf65d4..ba2fa51 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,3 +1,3 @@ #!/usr/bin/env sh -cmake -S . -B build -G Ninja -D CMAKE_EXPORT_COMPILE_COMMANDS=ON +cmake -S . -B .build -G Ninja -D CMAKE_EXPORT_COMPILE_COMMANDS=ON diff --git a/build.sh b/build.sh index 6479e4f..d26a5a3 100755 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ #!/usr/bin/env sh -cmake --build build +cmake --build .build diff --git a/test.sh b/test.sh index dd1e614..dd961ba 100755 --- a/test.sh +++ b/test.sh @@ -1,3 +1,3 @@ #!/usr/bin/env sh -cmake --build build && cmake --build build --target test +cmake --build .build && cmake --build .build --target test