Palm-Studios / sh3redux

SILENT HILL 3 Engine Remake in OpenGL and C++
GNU General Public License v3.0
162 stars 16 forks source link

CMake include_directories Error #134

Closed ghost closed 6 years ago

ghost commented 6 years ago

I think I have all dependencies satisfied. Here is the output:

$ cmake . -- The CXX compiler identification is GNU 7.3.1 -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test HAVE_fcolor-diagnostics_FLAG -- Performing Test HAVE_fcolor-diagnostics_FLAG - Failed -- Performing Test HAVE_fdiagnostics-color=always_FLAG -- Performing Test HAVE_fdiagnostics-color=always_FLAG - Success -- Forcing colored compiler output -- Performing Test HAVE_Weverything_FLAG -- Performing Test HAVE_Weverything_FLAG - Failed -- Performing Test HAVE_Wcxx98-compat_FLAG -- Performing Test HAVE_Wcxx98-compat_FLAG - Failed -- Performing Test HAVE_Wcxx98-compat-pedantic_FLAG -- Performing Test HAVE_Wcxx98-compat-pedantic_FLAG - Failed -- Performing Test HAVE_Wexit-time-destructors_FLAG -- Performing Test HAVE_Wexit-time-destructors_FLAG - Failed -- Performing Test HAVE_Wignored-qualifiers_FLAG -- Performing Test HAVE_Wignored-qualifiers_FLAG - Success -- Disabling -Wignored-qualifiers -- Performing Test HAVE_Wpadded_FLAG -- Performing Test HAVE_Wpadded_FLAG - Success -- Disabling -Wpadded -- Boost version: 1.66.0 -- Found GLEW: /usr/include
-- Found OpenGL: /usr/lib/libOpenGL.so
-- Found ZLIB: /usr/lib/libz.so (found version "1.2.11") CMake Error at source/CMakeLists.txt:16 (include_directories): include_directories given empty-string as include directory.

-- Boost version: 1.66.0 CMake Error at tests/CMakeLists.txt:16 (include_directories): include_directories given empty-string as include directory.

-- Found Doxygen: /usr/bin/doxygen (found version "1.8.14") found components: doxygen dot -- Configuring incomplete, errors occurred! See also "/home/broken/sh3redux/CMakeFiles/CMakeOutput.log". See also "/home/broken/sh3redux/CMakeFiles/CMakeError.log".

CMakeOutput.log CMakeError.log

Quaker762 commented 6 years ago

Paging doctor @z33ky

What version of Linux are you using? CMake Error at source/CMakeLists.txt:16 (include_directories): points to an issue with your install of SDL2 (as in it can't find the include directories for it). Maybe try running a reinstall of it with whatever package manager you use.

ghost commented 6 years ago

I use Arch Linux. I tried reinstalling sdl2 but no success, its version is 2.0.8-5. Do I have to install some additional packages/libraries of sdl2?

Quaker762 commented 6 years ago

@brokenechored I just checked on my Arch machine, I get the exact same error. Someone must have pushed something bad to one of the pacman packages... The source/CMakeLists.txt hasn't been touched since October last year.

@z33ky Someone's fucked something up big time

I'll post something on the Arch reddit page.

EDIT: I've also posted it to the arch forums here: https://bbs.archlinux.org/viewtopic.php?pid=1777835#p1777835

z33ky commented 6 years ago

sigh Yes, it seems the SDL2 CMake config broke backwards compatibility. We should probably copy the CMake files of our dependencies into our repository, but I have not been able to find out what the usually policy on this is since I'd normally trust the distribution more than whatever a repository has.

Newer CMake has this convenient feature where you just link against a target and includes and such are automatically set. However, this also requires a sufficiently recent CMake config file, which is why I have been using the old-style method.

Use this patch as a workaround:

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 2643b05..045c128 100644
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -7,6 +7,9 @@ find_package(OpenGL REQUIRED)
 find_package(SDL2 REQUIRED)
 find_package(ZLIB REQUIRED)

+get_target_property(SDL2_INCLUDE_DIRS SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
+set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIRS}/SDL2")
+
 include_directories("../include")
 include_directories(SYSTEM "../third_party/debugbreak")
 include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6d3906e..b30d574 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -7,6 +7,9 @@ find_package(OpenGL REQUIRED)
 find_package(SDL2 REQUIRED)
 find_package(ZLIB REQUIRED)

+get_target_property(SDL2_INCLUDE_DIRS SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
+set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIRS}/SDL2")
+
 include_directories("../include")
 include_directories(SYSTEM "../third_party/debugbreak")
 include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")
ghost commented 6 years ago

@z33ky Can't apply:

$ patch < CMakeLists.patch patching file CMakeLists.txt Hunk #1 FAILED at 7. 1 out of 1 hunk FAILED -- saving rejects to file CMakeLists.txt.rej patching file CMakeLists.txt Hunk #1 FAILED at 7. 1 out of 1 hunk FAILED -- saving rejects to file CMakeLists.txt.rej

Am I doing this wrong?

z33ky commented 6 years ago

Use git apply. Or patch -p1 (from the top of my head, might be wrong) to strip the a/ and b/ from the paths in the patch file.

ghost commented 6 years ago

@z33ky I've managed to apply it with $ git apply --reject --whitespace=fix CMakeLists.patch because everything else was failing.

Checking patch source/CMakeLists.txt...
Checking patch tests/CMakeLists.txt...
Applied patch source/CMakeLists.txt cleanly.
Applied patch tests/CMakeLists.txt cleanly.

It passes configuring but I get build errors now.

[ 25%] Building CXX object source/CMakeFiles/sh3rd.dir/SH3/system/log.cpp.o
[ 26%] Building CXX object source/CMakeFiles/sh3rd.dir/SH3/system/window.cpp.o
[ 28%] Linking CXX executable ../bin/sh3rd
CMakeFiles/sh3rd.dir/main.cpp.o: In function `main':
/home/broken/sh3redux/source/main.cpp:108: undefined reference to `SDL_PollEvent'
/home/broken/sh3redux/source/main.cpp:117: undefined reference to `SDL_GL_SwapWindow'
CMakeFiles/sh3rd.dir/main.cpp.o: In function `sdl_destroyer::operator()(SDL_Window*) const':
/home/broken/sh3redux/source/../include/SH3/system/sdl_destroyer.hpp:23: undefined reference to `SDL_DestroyWindow'
CMakeFiles/sh3rd.dir/main.cpp.o: In function `sdl_destroyer::operator()(void*) const':
/home/broken/sh3redux/source/../include/SH3/system/sdl_destroyer.hpp:24: undefined reference to `SDL_GL_DeleteContext'
CMakeFiles/sh3rd.dir/SH3/system/assert.cpp.o: In function `bool ask_msgbox<4ul>(AskAction&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::array<SDL_MessageBoxButtonData, 4ul> const&)':
/home/broken/sh3redux/source/SH3/system/assert.cpp:73: undefined reference to `SDL_ShowMessageBox'
CMakeFiles/sh3rd.dir/SH3/system/glcontext.cpp.o: In function `sh3_gl::context::context(sh3_window&)':
/home/broken/sh3redux/source/SH3/system/glcontext.cpp:129: undefined reference to `SDL_GL_SetAttribute'
/home/broken/sh3redux/source/SH3/system/glcontext.cpp:130: undefined reference to `SDL_GL_SetAttribute'
/home/broken/sh3redux/source/SH3/system/glcontext.cpp:131: undefined reference to `SDL_GL_SetAttribute'
/home/broken/sh3redux/source/SH3/system/glcontext.cpp:133: undefined reference to `SDL_GL_CreateContext'
/home/broken/sh3redux/source/SH3/system/glcontext.cpp:141: undefined reference to `SDL_GL_SetAttribute'
/home/broken/sh3redux/source/SH3/system/glcontext.cpp:142: undefined reference to `SDL_GL_SetAttribute'
/home/broken/sh3redux/source/SH3/system/glcontext.cpp:143: undefined reference to `SDL_GL_SetAttribute'
/home/broken/sh3redux/source/SH3/system/glcontext.cpp:144: undefined reference to `SDL_GL_SetAttribute'
/home/broken/sh3redux/source/SH3/system/glcontext.cpp:145: undefined reference to `SDL_GL_SetAttribute'
CMakeFiles/sh3rd.dir/SH3/system/glcontext.cpp.o:/home/broken/sh3redux/source/SH3/system/glcontext.cpp:146: more undefined references to `SDL_GL_SetAttribute' follow
CMakeFiles/sh3rd.dir/SH3/system/input.cpp.o: In function `sh3::system::input_system::raw::raw(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/broken/sh3redux/source/SH3/system/input.cpp:99: undefined reference to `SDL_GetScancodeFromName'
CMakeFiles/sh3rd.dir/SH3/system/log.cpp.o: In function `die(char const*, ...)':
/home/broken/sh3redux/source/SH3/system/log.cpp:95: undefined reference to `SDL_ShowSimpleMessageBox'
CMakeFiles/sh3rd.dir/SH3/system/window.cpp.o: In function `sh3_window::sh3_window(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
/home/broken/sh3redux/source/SH3/system/window.cpp:28: undefined reference to `SDL_CreateWindow'
collect2: error: ld returned 1 exit status
make[2]: *** [source/CMakeFiles/sh3rd.dir/build.make:515: bin/sh3rd] Error 1
make[1]: *** [CMakeFiles/Makefile2:118: source/CMakeFiles/sh3rd.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
z33ky commented 6 years ago

everything else was failing

Perhaps a missing '\n' at the end of the file?

It passes configuring but I get build errors now.

Ah, also add get_target_property(SDL2_LIBRARIES SDL2::SDL2 IMPORTED_LOCATION_NOCONFIG).

ghost commented 6 years ago

@z33ky I'm sorry, I barely know anything about patching. That's the first time I had to do something like this. Could you please show me how the file would look like with this? Ah, also add get_target_property(SDL2_LIBRARIES SDL2::SDL2 IMPORTED_LOCATION_NOCONFIG).

z33ky commented 6 years ago

Yeah sure. Just for clarification, in UNIX/Linux text-files usually always end with a '\n'. patch and git apply seem to choke on patches where this is not the case. Some editors automatically add the trailing new-line and don't even necessarily show it (at least Vim does, which I use).

Anyway, put the get_target_property(SDL2_LIBRARIES SDL2::SDL2 IMPORTED_LOCATION_NOCONFIG) just after set(SDL2_INCLUDE_DIRS "${SDL2_INCLUDE_DIRS}/SDL2") in both source/CMakeLists.txt and tests/CMakeLists.txt.

Don't hesitate to ask if you encounter more problems or have any other questions. Perhaps we should setup an IRC channel or something. @Quaker762 what do you think?

ghost commented 6 years ago

@z33ky thank you. This worked and the project builds. But the executables don't launch properly. This is the line that is constatly being written to log: [fatal] API (ERROR): GL_INVALID_OPERATION in glUseProgram(program 1 not linked)

log.txt

z33ky commented 6 years ago

Launch from the top-level folder, or link (ln -s ../data .) or copy (cp -r ../data .) the data-directory to the build directory. I'd make sense to document this... I just noticed that @Quaker762 modified the shaders when adding the Camera, so currently only the cam binary will render something visible.

ghost commented 6 years ago

I got it, thanks. cam runs with no issue. I guess we can close this thread.

Quaker762 commented 6 years ago

I just noticed that @Quaker762 modified the shaders when adding the Camera, so currently only the cam binary will render something visible.

Whoops.... I really need to change that some time soon, though both binaries are basically the same thing.

@brokenechored If you're interested in helping with the RE efforts, there's an sh3tools branch on my fork that hasn't been merged you should be able to build that'll give you information about any file you give it.

Also if you're interested, I have the source for the silent hill level viewer that I'm using for some of the formats. I can upload it here if you're interested.

ghost commented 6 years ago

@Quaker762 I've actually looked at sh3tools before at https://github.com/Palm-Studios/sh3tools but I was confused because there is no makefile. Level viewer would be nice to have, @Bigmanjapan would be also interested I think. Also I wanna say that I'm really bad at all of this. I started learning about building very recently and don't know much about features of git.

Quaker762 commented 6 years ago

@Quaker762 I've actually looked at sh3tools before at https://github.com/Palm-Studios/sh3tools but I was confused because there is no makefile.

I need to delete that repo, it's the original project that's no longer maintained.

Also I wanna say that I'm really bad at all of this. I started learning about building very recently and don't know much about features of git.

That's no problem. As long as you know basic C/C++ and math it's all good, I still don't know a lot about git myself. If you want to contribute, you first need to fork this project into your account, pull that copy to your computer and then work on a feature after doing a git branch (which creates a branch for you to work on). One that's done, open a pull request and get myself or @z33ky to review it (you're better getting Alex and not myself for that hahaha).

Also, here's the code for the level and model viewer. You can't build it, but it gives a great deal of detail into how some of the file formats work, which is what we're implementing at the moment. It'd be preferable for us to get level's loaded, as well as some camera stuff/camera constraint boxes (shown in the video by @Bigmanjapan) working first. SH_initial_loader.zip shloaderthelastfiles.zip shnextmissingfile.zip

ghost commented 6 years ago

@Quaker762 thanks a lot! I'll look into that.