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

Check for shared ENet if USE_SHARED_ENET is set #825

Open
rootkea opened this issue Oct 11, 2023 · 5 comments
Open

Check for shared ENet if USE_SHARED_ENET is set #825

rootkea opened this issue Oct 11, 2023 · 5 comments

Comments

@rootkea
Copy link
Contributor

rootkea commented Oct 11, 2023

Hello!

When I ask to use the shared ENet (-DUSE_SHARED_ENET=ON) cmake doesn't check for the enet unlike SDL2. And so build files get written without any issue. It's the ninja which fails since it can't find the enet as it's not installed on the system.

I tried to check for enet in CMakeLists.txt but couldn't fix the issue as it seems we need to write FindENet.cmake. This is what I tried:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 61b486b1..ceba1328 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,7 +83,9 @@ else()
     set(ENet_LIBRARIES ${ENet_LIBRARY})
 endif()
 
-if(NOT USE_SHARED_ENET)
+if(USE_SHARED_ENET)
+    find_package(enet REQUIRED)
+else()
     include_directories(src/cdogs/enet/include)
 endif()
 
@@ -309,7 +311,7 @@ else()
        # debian specific
        set(CPACK_DEBIAN_PACKAGE_MAINTAINER "C-Dogs SDL Team")
        set(CPACK_DEBIAN_PACKAGE_SECTION Games)
-       set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libsdl2-image, libsdl2-mixer")
+       set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libsdl2-image, libsdl2-mixer, libenet")
 
        # fedora/suse specific
        set(CPACK_RPM_PACKAGE_LICENSE "GPL2")
@rootkea
Copy link
Contributor Author

rootkea commented Oct 11, 2023

I did find FindENet.cmake at https://github.com/stuntrally/stuntrally/blob/master/cmake/FindENet.cmake but I'm a cmake newbie so not sure exactly which part is relevant to us...

@rootkea
Copy link
Contributor Author

rootkea commented Oct 11, 2023

BTW, ENet provides libenet.pc so maybe we can use pkg-config within cmake instead of maintaining our own FindENet.cmake?

  1. https://stackoverflow.com/questions/29191855/what-is-the-proper-way-to-use-pkg-config-from-cmake
  2. https://cmake.org/cmake/help/latest/module/FindPkgConfig.html

@rootkea
Copy link
Contributor Author

rootkea commented Oct 12, 2023

Moreover, I'm sorry but is there a strong a reason to maintain our own ENet in cdogs-sdl source? I mean upstream seems pretty active. Why aren't we upstreaming our ENet patches https://github.com/cxong/cdogs-sdl/commits/master/src/cdogs/enet ? It should ease the maintenance and also good for FLOSS. :)

@reinerh
Copy link
Contributor

reinerh commented Oct 21, 2023

BTW, ENet provides libenet.pc so maybe we can use pkg-config within cmake instead of maintaining our own FindENet.cmake?

In my opinion using pkg-config to find ENet would be better than writing and maintaining a custom CMake module that searches it.

@cxong
Copy link
Owner

cxong commented Oct 26, 2023

It would be good to upstream any changes, but testing enet / networking is a lot of work, happy if anyone else is willing to look at it

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

No branches or pull requests

3 participants