cpputest
cpputest copied to clipboard
PROJECT_IS_TOP_LEVEL while using externalproject_add
While using externalproject_add, CMakeLists.txt file is forcing some options based on PROJECT_IS_TOP_LEVEL.
While building for a target platform (different toolchain) I don't want to build and run those tests or some of options set by the "top level".
Please be more specific.
If I build cpputest with externalproject_add, this will make that the build is detected as a "top level" project https://github.com/cpputest/cpputest/blob/6f66733f7a1affc05a5ad2126d5c5eecf82f662f/CMakeLists.txt#L12 however, I want to still build it as a lib to be integrated and don't want it builds tests and try to run it.
If I build cpputest with externalproject_add
I strongly encourage you to use FetchContent instead of ExternalProject. ExternalProject will create a totally separate build for CppUTest that will not inherit any of the settings of the parent project.
this will make that the build is detected as a "top level" project
PROJECT_IS_TOP_LEVEL is evaluating as true because ExternalProject is creating a totally independent build.
I want to still build it as a lib
It will still build as a library
[I] don't want it builds tests and try to run it
You can override any of the options controlling these settings
@basvodde This is expected behavior. I think you can close this issue.
If I build cpputest with externalproject_add
I strongly encourage you to use FetchContent instead of ExternalProject. ExternalProject will create a totally separate build for CppUTest that will not inherit any of the settings of the parent project.
How can I pass the cross-compiler (and eventually other options) in this case?
I'll let it open just for the discussion for the next days, then close. Thanks!
If I build cpputest with externalproject_add
I strongly encourage you to use FetchContent instead of ExternalProject. ExternalProject will create a totally separate build for CppUTest that will not inherit any of the settings of the parent project.
How can I pass the cross-compiler (and eventually other options) in this case?
That is the default behavior of FetchContent.
I'm trying to use FetchContent it builds, but I see it sets the CPP_PLATFORM to Gcc and then
/opt/esp/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: _deps/cpputest-build/src/CppUTest/libCppUTest.a(UtestPlatform.cpp.obj): in function `_ZL37PlatformSpecificWaitPidImplementationiPii':
/workspaces/dte_communications/build_unit_tests/_deps/cpputest-src/src/Platforms/Gcc/UtestPlatform.cpp:146:(.text+0x86): undefined reference to `waitpid'
Maybe I should be able to build my own UtestPlatform.cpp but I can't see how to override it using CMake options
I would try overriding the platform to armcc which tends to be more compatible with bare metal projects.
I'm trying to use FetchContent it builds, but I see it sets the CPP_PLATFORM to Gcc and then
/opt/esp/tools/xtensa-esp-elf/esp-13.2.0_20240530/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/13.2.0/../../../../xtensa-esp-elf/bin/ld: _deps/cpputest-build/src/CppUTest/libCppUTest.a(UtestPlatform.cpp.obj): in function `_ZL37PlatformSpecificWaitPidImplementationiPii': /workspaces/dte_communications/build_unit_tests/_deps/cpputest-src/src/Platforms/Gcc/UtestPlatform.cpp:146:(.text+0x86): undefined reference to `waitpid'Maybe I should be able to build my own UtestPlatform.cpp but I can't see how to override it using CMake options
Your compiler is finding waitpid but your linker isn't. You can try overriding it before you call FetchContent:
set(CPPUTEST_HAVE_WAITPID OFF CACHE BOOL "" FORCE)
# ...
FetchContent_Declare(cpputest
# ...
)