diff options
| author | Eric Joldasov <bratishkaerik@getgoogleoff.me> | 2024-05-14 20:00:17 +0500 |
|---|---|---|
| committer | Eric Joldasov <bratishkaerik@landless-city.net> | 2024-05-14 23:40:41 +0500 |
| commit | b59c722a3fed1b873d4f82f38d248775bfe23ae4 (patch) | |
| tree | c1eb6f35951ba92531085cc8ebbdfe6df7c001c0 /cmake | |
| parent | c2ad0220e0653ba0c481eb65fb468b0dcaba4bac (diff) | |
| download | zig-b59c722a3fed1b873d4f82f38d248775bfe23ae4.tar.gz zig-b59c722a3fed1b873d4f82f38d248775bfe23ae4.zip | |
CMake: clean `CMAKE_{SOURCE,BUILD}_DIR`
Replace `CMAKE_SOURCE_DIR` and `CMAKE_BUILD_DIR` with different variables,
or in some cases just remove them.
For some function arguments, prepended `CMAKE_SOURCE_DIR` was removed without
replacement. This includes:
* Sources for `add_library` and `add_executable` (`ZIG_CPP_SOURCES` and `ZIG_WASM2C_SOURCES`)
* Inputs for `configure_file` and `target_include_directory`
* For arguments above, CMake already prepends
`CMAKE_CURRENT_SOURCE_DIR` to them by default, if they are relative paths.
Additionaly, it was removed from arguments of commands that have `WORKING_DIRECTORY` set to
`PROJECT_SOURCE_DIR`, they will be similarly converted by CMake for us.
Also:
* Move project declaration to the top so that these variables are
available earlier.
* Avoid calling "git" executable if ".git" directory does not exist.
* Swap "--prefix" and `ZIG_BUILD_ARGS` arguments in cmake/install.cmake
to match same "zig2 build" command in CMakeLists.txt and allow
overriding "--prefix" argument
Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
Diffstat (limited to 'cmake')
| -rw-r--r-- | cmake/install.cmake | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/cmake/install.cmake b/cmake/install.cmake index 4a8356313e..86fd3fb17c 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -1,7 +1,7 @@ -set(ZIG_INSTALL_ARGS build ${ZIG_BUILD_ARGS} --prefix "${CMAKE_INSTALL_PREFIX}") +set(ZIG_INSTALL_ARGS build --prefix "${CMAKE_INSTALL_PREFIX}" ${ZIG_BUILD_ARGS}) execute_process( COMMAND "${ZIG_EXECUTABLE}" ${ZIG_INSTALL_ARGS} - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" RESULT_VARIABLE _result) if(_result) |
