Reputation: 14308
If I do:
#include <exception>
#include <iostream>
int main(int argc, char* argv[])
{
std::set_terminate([]() {
std::cout << "Called terminate handler";
});
std::terminate();
}
The terminate handler gets called. However if in my CMake project I do:
add_subdirectory(my_library_directory)
target_link_libraries(my_target PUBLIC Jolt)
Specifically the target_link_libraries
command then makes it so that my set_terminate()
function in my main doesn't work anymore. My handler isn't called anymore. This seems like really weird behaviour, and it's difficult to figure out what's happening because Jolt links to a bunch of other libraries and dependencies, and I can't comment things out to figure out what's causing it because if I comment something out the program will no longer compile or link.
Is there any reason why this may be the case? Obviously I know it's the specific command:
target_link_libraries(my_target PUBLIC Jolt)
That's causing this problem, is there like a setting or a compiler flag that could have been set that when I link to this library disables the terminate handler being called?
I provided a minimal reproducible example at:
https://github.com/Please-just-dont/LinkingJoltExample
Upvotes: 3
Views: 84