ned14 / outcome

Provides very lightweight outcome<T> and result<T> (non-Boost edition)
https://ned14.github.io/outcome
Other
676 stars 62 forks source link

Superbuilding / installing outcome for targets without `execinfo.h`. #231

Closed burnpanck closed 4 years ago

burnpanck commented 4 years ago

I have previously been using outcome using add_submodule, now I'm trying to switch to a super-build scheme, where the configuration step of my application builds and installs it's dependencies into the build folder, for immediate consumption by find_package. My target is a bare-metal ARM embedded microcontroller system. The corresponding toolchain is non-posix and does not offer an execinfo.h. Using outcome works nonetheless thanks to the OUTCOME_DISABLE_EXECINFO flag.

Unfortunatley, I cannot install outcome using the usual cmake process in the superbuild, because building the tests fails due to the missing execinfo.h. Of course, I can workaround by simply using the single-header versions of outcome, but I would prefer to properly "linking" to outcome using the usual modular CMake targets. Is there a way to configure the build of outcome with either the tests disabled or OUTCOME_DISABLE_EXECINFO set (not using CMAKE_CXX_FLAGS because that interferes with the CMAKE_TOOLCHAIN_FILE needed for my target toolchain - at least it didn't work for me)?

I haven't been able to work through the internals of quickcpplib yet to fully understand and potentially add such an option.

burnpanck commented 4 years ago

...I was able to fix my toolchain file so it does let me pass OUTCOME_DISABLE_EXECINFO through CMAKE_CXX_FLAGS. With that, I can actually install outcome correctly. To use it however, I also need to install quickcpplib, which again fails at the tests, this time due to lack for threading. Same problem; how do I instruct quickcpplib not to perform the tests, or is there a configuration flag specifically for standalone systems? Should I close and open an issue in quickcpplib?

ned14 commented 4 years ago

I was just about to say that I really think that's a toolchain file fix. Good to see you got that working.

For preventing tests, try setting PROJECT_IS_DEPENDENCY=On for the cmake. This skips anything which superbuild doesn't need, like tests.

burnpanck commented 4 years ago

Ah stupid, I had missed the only obvious CMake variable in the top-level CMakeLists.txt. Indeed, with that flag set for both quickcpplib and outcome, I am able to successfully superbuild on my target.

ned14 commented 4 years ago

Normally PROJECT_IS_DEPENDENCY is set to on for you if you bring in anything via add_subdirectory(). This speeds things up considerably. However, when building for install, there is every reason to think that you do want to run tests etc before install, so it defaults to off. There is no concern about overriding it. Good to know you got things working!