generated from threeal/cmake-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto-specify build type for building external packages (#159)
* feat: auto-define `CMAKE_BUILD_TYPE` in `cdeps_build_package` function Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com> * test: specify minimum required CMake version in some test scripts Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com> --------- Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
- Loading branch information
Showing
7 changed files
with
82 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
cmake_minimum_required(VERSION 3.21) | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/../cmake/CDeps.cmake) | ||
|
||
set(CDEPS_ROOT .cdeps) | ||
file(REMOVE_RECURSE .cdeps) | ||
|
||
file(WRITE .cdeps/pkg/src/CMakeLists.txt | ||
"cmake_minimum_required(VERSION 3.5)\n" | ||
"project(pkg LANGUAGES NONE)\n" | ||
"set(BUILD_TYPE \"\${CMAKE_BUILD_TYPE}\" CACHE STRING \"\" FORCE)\n") | ||
|
||
file(WRITE .cdeps/pkg/src.lock "pkg github.com/user/pkg main") | ||
|
||
section("it should build a package without a build type specified") | ||
cdeps_build_package(pkg) | ||
|
||
section("it should generate the lock file") | ||
file(READ .cdeps/pkg/build.lock CONTENT) | ||
assert(CONTENT MATCHES [^OPTIONS]) | ||
endsection() | ||
endsection() | ||
|
||
section("it should rebuild the package with the main project build type") | ||
block() | ||
set(CMAKE_BUILD_TYPE Release) | ||
cdeps_build_package(pkg) | ||
endblock() | ||
|
||
section("it should regenerate the lock file") | ||
file(READ .cdeps/pkg/build.lock CONTENT) | ||
assert(CONTENT MATCHES "OPTIONS CMAKE_BUILD_TYPE=Release$") | ||
endsection() | ||
|
||
section("it should rebuild with the correct build type") | ||
assert_execute_process( | ||
COMMAND ${CMAKE_COMMAND} -L -N .cdeps/pkg/build | ||
OUTPUT "BUILD_TYPE:STRING=Release") | ||
endsection() | ||
endsection() | ||
|
||
section("it should rebuild the package with the specified build type") | ||
block() | ||
set(CMAKE_BUILD_TYPE Release) | ||
cdeps_build_package(pkg OPTIONS CMAKE_BUILD_TYPE=RelWithDebInfo) | ||
endblock() | ||
|
||
section("it should regenerate the lock file") | ||
file(READ .cdeps/pkg/build.lock CONTENT) | ||
assert(CONTENT MATCHES "OPTIONS CMAKE_BUILD_TYPE=RelWithDebInfo$") | ||
endsection() | ||
|
||
section("it should rebuild with the correct build type") | ||
assert_execute_process( | ||
COMMAND ${CMAKE_COMMAND} -L -N .cdeps/pkg/build | ||
OUTPUT "BUILD_TYPE:STRING=RelWithDebInfo") | ||
endsection() | ||
endsection() |
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