-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Specify source AND binary dirs in
add_rust_*
fun. Breaks API!
Changed the `add_rust_*` functions to have SOURCE_DIRECTORY and BINARY_DIRECTORY parameters instead of WORKING_DIRECTORY. This allows you to build and run the Rust unit tests from the same BINARY_DIRECTORy as you do for the Rust library build. That means it won't recompile all of the dependencies when building the unit test executable. A side-effect of this change is that the CMakeLists.txt file that uses `add_rust_library()` must be in the same directory as the Rust module. I.e. you should co-locate the CMakeLists.txt with the Cargo.toml file. You can no longer have a parent directory's CMakeFiles.txt add a library for a subdirectory. The reason is that CMake will set the INTERFACE_INCLUDE_DIRECTORIES property for your library's CMake target use both the SOURCE_DIRECTORY and BINARY_DIRECTORY. This ensures that generated headers will be placed in the include path for any downstream CMake targets. CMake requires both directories to exist. When CMake does the build, it will create subdirectories in the build path for each CMakeLists.txt file. Co-locating CMakeLists.txt with Cargo.toml ensures that the BUILD_DIRECTORY is automatically created by CMake. Important: This commit breaks the API for the FindRust.cmake module!
- Loading branch information
Showing
7 changed files
with
118 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
# Copyright (C) 2020-2022 Micah Snyder. | ||
|
||
# | ||
# Libraries that may be used by the applications. | ||
# | ||
|
||
# A library to generate UUID's | ||
add_rust_library(TARGET gen_uuid WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/gen_uuid") | ||
|
||
# The unit tests for this module have no dependencies on C libraries or other special | ||
# test environment considerations, so we may as well add the test right here instead of | ||
# adding it in the `test/CMakeLists.txt` file. | ||
add_rust_test(NAME gen_uuid WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/gen_uuid") | ||
add_library(demo::gen_uuid ALIAS gen_uuid) | ||
add_subdirectory(gen_uuid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright (C) 2020-2022 Micah Snyder. | ||
|
||
# | ||
# Libraries that may be used by the applications. | ||
# | ||
|
||
# A library to generate UUID's | ||
add_rust_library(TARGET gen_uuid | ||
SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
BINARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" | ||
) | ||
|
||
# The unit tests for this module have no dependencies on C libraries or other special | ||
# test environment considerations, so we may as well add the test right here instead of | ||
# adding it in the `test/CMakeLists.txt` file. | ||
add_rust_test(NAME gen_uuid | ||
SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
BINARY_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" | ||
) | ||
add_library(demo::gen_uuid ALIAS gen_uuid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters