Closed jmarca closed 4 years ago
Thanks for the report! There seems to be indeed a bug when making an executable, since the tests are linking against it, as if it were a library. For the moment, you can turn of unit testing (i.e. cmake .. -DProject_BUILD_EXECUTABLE=On -DProject_ENABLE_UNIT_TESTING=0
), while I try to figure out a solution which would not eliminate unit testing from the project.
I think this line cause the error. https://github.com/filipdutescu/modern-cpp-template/blob/1974980aced7b43ebdf5462d5cf99156929a6044/CMakeLists.txt#L56 and it's reasonable. There is a tmp.hpp file, and it's implementation file tmp.cpp. These are a library. If we want to use them as an executable, either the tmp.cpp should provide a main file or there must be another file that include main function and that file should be the executable. I think it's better to remove the option at all.
@jmarca fixed the problem in b53aec0
. Could you confirm it works for you as well?
Apologies but I haven’t had time to test this. If I get to it I’ll reopen
James
On Aug 15, 2020, at 02:26, Filip Dutescu notifications@github.com wrote:
Closed #16 via eea7e38.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Describe the bug If I try to build executable by setting -DProject_BUILD_EXECUTABLE=On, the cmake step fails with
To Reproduce Steps to reproduce the behavior:
Expected behavior I'm just trying to build a simple executable, not a library
Desktop (please complete the following information):
cmake --version cmake version 3.16.3
Additional context Coming back to C++ after forever away, just learning about the build tooling etc, so it could be a basic mistake on my end. Just want to build an executable program not a library. I failed after tweaking things for my project, and then got the same failure in the vanilla template project with no tweaks.