Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile error with gcc9.1 on linux #1636

Closed
alanhaw opened this issue May 19, 2019 · 7 comments · Fixed by #1638
Closed

compile error with gcc9.1 on linux #1636

alanhaw opened this issue May 19, 2019 · 7 comments · Fixed by #1638

Comments

@alanhaw
Copy link

alanhaw commented May 19, 2019

Compile error when building catch2, from the repository.

cloned catch2 yesterday (May 18,2019) with:
git clone https://github.com/catchorg/Catch2.git
into a folder catch2.
Then started a build in that folder with
cmake .
make

This produced the following error:
[ 99%] Building CXX object projects/CMakeFiles/SelfTest.dir/SelfTest/SurrogateCpps/catch_xmlwriter.cpp.o
[100%] Linking CXX executable SelfTest
/usr/bin/ld: cannot open output file SelfTest: Is a directory
collect2: error: ld returned 1 exit status
projects/CMakeFiles/SelfTest.dir/build.make:1703: recipe for target 'projects/SelfTest' failed
make[2]: *** [projects/SelfTest] Error 1
CMakeFiles/Makefile2:986: recipe for target 'projects/CMakeFiles/SelfTest.dir/all' failed
make[1]: *** [projects/CMakeFiles/SelfTest.dir/all] Error 2
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2
alan@alan-SH67H3:~/projects/functional/code-examples/3rd-party/catchorg/Catch2$

This looks like an error that was previously encountered and has resurrected itself.

Platform information:
This is on x86_64 with ubuntu 18.04.2
Using gcc 9.1.0
and cmake 3.14.4
and GNU make 4.1

@AlexisWilke
Copy link

So I can compile everything, I added the set_target_properties() as follow:

add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS})
target_include_directories(SelfTest PRIVATE ${HEADER_DIR})
set_target_properties(SelfTest PROPERTIES OUTPUT_NAME SelfTest.exe)

This is in the projects/CMakeLists.txt file. That's probably not the right solution, but I could still run the executable and the 1245 assertions worked as expected.

@alanhaw
Copy link
Author

alanhaw commented May 20, 2019

That worked! Thank you.

@JoeyGrajciar
Copy link
Contributor

JoeyGrajciar commented May 20, 2019

Just to be sure. Did you follow https://github.com/catchorg/Catch2/blob/master/projects/Where%20did%20the%20projects%20go.txt ?
Usually the folder to build catch2 should be located at <wherever Catch2 folder is>/projects/Generated.
After that from Generated folder running cmake -G <generator name> ../.. does the trick

@AlexisWilke
Copy link

AlexisWilke commented May 20, 2019

Oooh... That worked. Either way, this is really not conventional for cmake though.

What I do with nearly all projects is extract the code:

tar xf catch2.tar.gz

Then I create a build folder

mkdir BUILD

and cd into it to run cmake and make:

cd BUILD
cmake ../catch2
make

Any reason why you had to break the usual scheme?

Doing so with catch2 fails completely. The cmake command from my BUILD folder says it can't find this and/or that. Files you should be able to find using ${CMAKE_SOURCE_DIR}. So the next best thing was to run cmake in the root folder... (again, that's the expected cmake usage, separate build folder or the root folder of the source package.)

Maybe a ${CMAKE_MODULE_PATH} not updated properly? I often add my project/cmake folder like so:

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

Anyway. The Generated folder is better than having to apply a patch! :-)

janisozaur added a commit to janisozaur/Catch2 that referenced this issue May 21, 2019
@horenmar
Copy link
Member

@AlexisWilke just generating any folder different from the source folder should work, my work flow is to just do

cd Catch2-foo
CXX=clang++ cmake -Bclang-build -H.
make -C clang-build

for linux builds and it works.

The original error was caused by building in the source directory, which is generally bad idea and CMake will now error out rather than do it.

@horenmar
Copy link
Member

@JoeyGrajciar That file is terrible and no longer exists 😃

@AlexisWilke
Copy link

Ah! Great. I tested with the latest from git and that worked even with a folder outside of the tree. Great!

Maybe you need a new release with a fix to the file Joey's mentioned above...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants