Saturday, October 03, 2020

Re: update games/barony - looking for help with cmake

On Sat, Oct 03, 2020 at 11:09:51PM +0200, Rafael Sadowski wrote:
> On Sat Oct 03, 2020 at 10:19:12PM +0200, Solene Rapenne wrote:
> > This diff updates barony to version 3.3.7 which
> > matches the version available on GOG for download
> > and should bring support for latest DLC that I don't
> > own so I didn't test.
> >
> > I had to patch the thread library detection and rework the patch
> > on the CMake because the original file changed too much.
> >
> > Rapidjson is now required, I added a new DISTFILE and an environment
> > variable to cmake to gives the path to the files.
> >
> > I have one issue though that I made a really ugly fix to be able
> > to continue and check if the engine was working with the assets.
> >
> > It seems cmake doesn't copy the "lang" directory at the build time
> > and fails during fake-target
> >
> > ===> Faking installation for barony-3.3.7
> > [0/1] cd /home/build/usr/ports/pobj/barony-3.3.7/build-amd64 && /usr/local/bin/cmake -P cmake_install.cmake
> > -- Install configuration: "Release"
> > -- Installing: /home/build/usr/ports/pobj/barony-3.3.7/fake-amd64/usr/local/bin/barony-bin
> > -- Installing: /home/build/usr/ports/pobj/barony-3.3.7/fake-amd64/usr/local/bin/barony-editor
> > CMake Error at cmake_install.cmake:89 (file):
> > file INSTALL cannot find
> > "/home/build/usr/ports/pobj/barony-3.3.7/build-amd64/lang": No such file or
> > directory.
> >
> > FAILED: CMakeFiles/install.util
> > cd /home/build/usr/ports/pobj/barony-3.3.7/build-amd64 && /usr/local/bin/cmake -P cmake_install.cmake
> > ninja: build stopped: subcommand failed.
> > *** Error 1 in . (/home/build/usr/ports/devel/cmake/cmake.port.mk:39 'do-install': @cd /home/build/usr/ports/pobj/barony-3.3.7/build-amd64 &...)
> > *** Error 2 in . (/home/build/usr/ports/infrastructure/mk/bsd.port.mk:3005 '/home/build/usr/ports/pobj/barony-3.3.7/fake-amd64/.fake_done')
> > *** Error 2 in . (/home/build/usr/ports/infrastructure/mk/bsd.port.mk:2116 '/home/build/usr/ports/packages/amd64/all/barony-3.3.7.tgz': @cd ...)
> > *** Error 2 in . (/home/build/usr/ports/infrastructure/mk/bsd.port.mk:2605 '_internal-package': @case X${_DEPENDS_CACHE} in X) _DEPENDS_CAC...)
> > *** Error 2 in . (/home/build/usr/ports/infrastructure/mk/bsd.port.mk:2584 'package': @:; cd /usr/ports/games/barony && PKGPATH=games/barony...)
> > *** Error 2 in . (/home/build/usr/ports/infrastructure/mk/bsd.port.mk:2137 '/var/db/pkg/barony-3.3.7/+CONTENTS': @cd /usr/ports/games/barony...)
> > *** Error 2 in /usr/ports/games/barony (/home/build/usr/ports/infrastructure/mk/bsd.port.mk:2584 'install': @lock=barony-3.3.7; export _LOC...)
> >
> >
> > My fix is the following, I don't know how to fix this in Cmake or
> > if it's okay enough to commit with this:
>
> You can change "${CMAKE_CURRENT_BINARY_DIR}/lang" to
> ${CMAKE_CURRENT_SOURCE_DIR}/lang or simply lang (without
> ${CMAKE_CURRENT_BINARY_DIR}/"). Full diff below.

Tested this builds and works with the latest game data
from the Epic store version, thanks!

-Bryan.

> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/games/barony/Makefile,v
> retrieving revision 1.6
> diff -u -p -u -p -r1.6 Makefile
> --- Makefile 18 Jun 2020 21:37:44 -0000 1.6
> +++ Makefile 3 Oct 2020 21:08:18 -0000
> @@ -1,6 +1,6 @@
> # $OpenBSD: Makefile,v 1.6 2020/06/18 21:37:44 solene Exp $
>
> -V = 3.2.3
> +V = 3.3.7
> COMMENT = 3D, first person roguelike
> PKGNAME = ${DISTNAME:L}
> CATEGORIES = games x11
> @@ -15,6 +15,11 @@ MAINTAINER = David Carlier <devnexen@gma
> # GPLv3 only
> PERMIT_PACKAGE = Yes
>
> +RAPIDJSON_V = 1.1.0
> +MASTER_SITES0 = https://github.com/Tencent/rapidjson/archive/
> +DISTFILES += Barony-${V}.tar.gz \
> + rapidjson-{}v${RAPIDJSON_V}.tar.gz:0
> +
> WANTLIB += ${COMPILER_LIBCXX} GL GLU SDL2 SDL2_image SDL2_net
> WANTLIB += SDL2_ttf c execinfo m ogg openal png vorbisfile physfs
>
> @@ -33,6 +38,7 @@ LIB_DEPENDS = audio/libvorbis \
> devel/sdl2-ttf \
> graphics/png
>
> +CONFIGURE_ENV = RAPID_JSONROOT="${WRKDIR}/rapidjson-${RAPIDJSON_V}/"
> CONFIGURE_ARGS = -DCMAKE_C_FLAGS="${CFLAGS}" \
> -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
> -DOPENAL_ENABLED=ON \
> Index: distinfo
> ===================================================================
> RCS file: /cvs/ports/games/barony/distinfo,v
> retrieving revision 1.3
> diff -u -p -u -p -r1.3 distinfo
> --- distinfo 18 Jun 2020 21:37:44 -0000 1.3
> +++ distinfo 3 Oct 2020 21:08:18 -0000
> @@ -1,2 +1,4 @@
> -SHA256 (Barony-3.2.3.tar.gz) = M0tAqqGtVXFQaBWqYBpw1B5L1EqnBqp52MIeChIlwm8=
> -SIZE (Barony-3.2.3.tar.gz) = 53508615
> +SHA256 (Barony-3.3.7.tar.gz) = oLiULiaeja/MQhcykryxvUrNHC3TXVtIOgpgWe8ne7M=
> +SHA256 (rapidjson-v1.1.0.tar.gz) = v3ztKXBKHmlvvM8qK06gaOd3T6N/bX3UA50Hh/i+2Y4=
> +SIZE (Barony-3.3.7.tar.gz) = 53830405
> +SIZE (rapidjson-v1.1.0.tar.gz) = 1019402
> Index: patches/patch-CMakeLists_txt
> ===================================================================
> RCS file: /cvs/ports/games/barony/patches/patch-CMakeLists_txt,v
> retrieving revision 1.2
> diff -u -p -u -p -r1.2 patch-CMakeLists_txt
> --- patches/patch-CMakeLists_txt 1 Oct 2018 12:00:12 -0000 1.2
> +++ patches/patch-CMakeLists_txt 3 Oct 2020 21:08:18 -0000
> @@ -7,109 +7,107 @@ game via a wrapper script, which is name
> Index: CMakeLists.txt
> --- CMakeLists.txt.orig
> +++ CMakeLists.txt
> -@@ -58,14 +58,14 @@ if( NOT WIN32 )
> - if(PANDORA)
> - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -ffast-math -funroll-loops -fstrict-aliasing -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -g -fuse-ld=gold -fuse-linker-plugin")
> - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall ")
> -- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -ffast-math -funroll-loops -fstrict-aliasing -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -g -fuse-ld=gold -fuse-linker-plugin -fsingle-precision-constant")
> -- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -ffast-math -funroll-loops -fstrict-aliasing -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -g -fuse-ld=gold -fuse-linker-plugin -fsingle-precision-constant")
> -+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math -funroll-loops -fstrict-aliasing -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -g -fuse-ld=gold -fuse-linker-plugin -fsingle-precision-constant")
> -+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -funroll-loops -fstrict-aliasing -mcpu=cortex-a8 -mfpu=neon -mfloat-abi=softfp -g -fuse-ld=gold -fuse-linker-plugin -fsingle-precision-constant")
> - else()
> - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -pg -ffast-math -funroll-loops -fstrict-aliasing")
> - #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -pg -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined -fno-sanitize-recover -Wreturn-type -Werror=return-type")
> - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -pg")
> -- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -ffast-math -funroll-loops -fstrict-aliasing")
> -- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
> -+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffast-math -funroll-loops -fstrict-aliasing")
> -+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ")
> - endif()
> - if (APPLE)
> - set (Apple 1)
> -@@ -255,7 +255,7 @@ message("${CMAKE_CXX_FLAGS_DEBUG}")
> - message("Release flags: ")
> - message("${CMAKE_C_FLAGS_RELEASE}")
> - message("${CMAKE_CXX_FLAGS_RELEASE}")
> --#-O3 -DNDEBUG -Wall -pg -ffast-math -funroll-loops -fstrict-aliasing
> -+# -DNDEBUG -Wall -pg -ffast-math -funroll-loops -fstrict-aliasing
> - message("***************************")
> -
> -
> -@@ -292,7 +292,7 @@ SET_SOURCE_FILES_PROPERTIES(${MACOSX_BUNDLE_ICON_FILE}
> - set_source_files_properties(${GAME_SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c++")
> - #set_source_files_properties(${GAME_SOURCES} PROPERTIES COMPILE_FLAGS "-stdlib=libc++")
> +@@ -14,7 +14,7 @@ endif()
> + if (DEFINED ENV{OPTIMIZATION_LEVEL})
> + set (OPTIMIZATION_LEVEL $ENV{OPTIMIZATION_LEVEL})
> else()
> --add_executable(barony ${GAME_SOURCES})
> -+add_executable(barony-bin ${GAME_SOURCES})
> +- set (OPTIMIZATION_LEVEL "-O3")
> ++ set (OPTIMIZATION_LEVEL "")
> endif()
>
> - if(WIN32)
> -@@ -309,9 +309,9 @@ if(WIN32)
> + if (DEFINED ENV{EOS_ENABLED})
> +@@ -363,7 +363,7 @@ if (APPLE)
> + #set_source_files_properties(${GAME_SOURCES} PROPERTIES COMPILE_FLAGS "-stdlib=libc++")
> else()
> - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
> - # 64 bit
> -- target_link_libraries(barony -L/usr/lib64 -lstdc++)
> -+ target_link_libraries(barony-bin -L/usr/lib64 -lstdc++)
> - endif()
> -- target_link_libraries(barony ${SDL2_LIBRARIES} ${SDL2_LIBRARY} ${SDL2IMAGE_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_NET_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${SDL2TTF_LIBRARY})
> -+ target_link_libraries(barony-bin ${SDL2_LIBRARIES} ${SDL2_LIBRARY} ${SDL2IMAGE_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_NET_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${SDL2TTF_LIBRARY})
> - if (STEAMWORKS_ENABLED)
> - target_link_libraries(barony ${STEAMWORKS_LIBRARY})
> - #target_link_libraries(barony ${STEAMWORKS_CWRAPPER_LIBRARIES} -lstdc++)
> -@@ -324,16 +324,16 @@ else()
> - find_path(EXECINFO_INC NAMES execinfo.h)
> - find_library(EXECINFO_LIB NAMES execinfo)
> - include_directories(${EXECINFO_INC})
> -- target_link_libraries(barony ${EXECINFO_LIB})
> -+ target_link_libraries(barony-bin ${EXECINFO_LIB})
> - endif()
> - endif()
> --target_link_libraries(barony ${OPENGL_LIBRARIES})
> --target_link_libraries(barony ${THREADS_LIBRARIES})
> --target_link_libraries(barony -lm -lc)
> -+target_link_libraries(barony-bin ${OPENGL_LIBRARIES})
> -+target_link_libraries(barony-bin ${THREADS_LIBRARIES})
> -+target_link_libraries(barony-bin -lm -lc)
> - if( NOT WIN32 AND NOT APPLE)
> - #Remember, Windows and Mac aren't using find_package for FMOD and PNG.
> -- target_link_libraries(barony ${PNG_LIBRARY})
> -- target_link_libraries(barony ${PHYSFS_LIBRARY})
> -+ target_link_libraries(barony-bin ${PNG_LIBRARY})
> -+ target_link_libraries(barony-bin ${PHYSFS_LIBRARY})
> - if (FMOD_FOUND)
> - target_link_libraries(barony ${FMOD_LIBRARY})
> - endif()
> -@@ -352,14 +352,14 @@ if(APPLE)
> - target_link_libraries(barony -lfmodex) #Finally manually link fmod for mac.
> - endif()
> - endif()
> --target_link_libraries(barony ${EXTRA_LIBS}) #Apple needs this for OpenGL to work.
> -+target_link_libraries(barony-bin ${EXTRA_LIBS}) #Apple needs this for OpenGL to work.
> -
> - if (OPENAL)
> -- target_link_libraries(barony ${OPENAL_LIBRARY})
> -+ target_link_libraries(barony-bin ${OPENAL_LIBRARY})
> - if(TREMOR_ENABLED)
> -- target_link_libraries(barony ${TREMOR_LIBRARY})
> -+ target_link_libraries(barony-bin ${TREMOR_LIBRARY})
> + if (GAME_ENABLED)
> +- add_executable(barony ${GAME_SOURCES})
> ++ add_executable(barony-bin ${GAME_SOURCES})
> + endif (GAME_ENABLED)
> + endif(APPLE)
> +
> +@@ -385,15 +385,15 @@ if (GAME_ENABLED)
> + else(WIN32)
> + if( ("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") AND (NOT APPLE) )
> + # 64 bit
> +- target_link_libraries(barony -L/usr/lib64 -lstdc++)
> ++ target_link_libraries(barony-bin -L/usr/lib64 -lstdc++)
> + endif()
> +- target_link_libraries(barony ${SDL2_LIBRARIES} ${SDL2_LIBRARY} ${SDL2IMAGE_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_NET_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${SDL2TTF_LIBRARY})
> ++ target_link_libraries(barony-bin ${SDL2_LIBRARIES} ${SDL2_LIBRARY} ${SDL2IMAGE_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_NET_LIBRARIES} ${SDL2_TTF_LIBRARIES} ${SDL2TTF_LIBRARY})
> + if (STEAMWORKS_ENABLED)
> +- target_link_libraries(barony ${STEAMWORKS_LIBRARY})
> ++ target_link_libraries(barony-bin ${STEAMWORKS_LIBRARY})
> + #target_link_libraries(barony ${STEAMWORKS_CWRAPPER_LIBRARIES} -lstdc++)
> + endif()
> + if (EOS_ENABLED)
> +- target_link_libraries(barony ${EOS_LIBRARIES})
> ++ target_link_libraries(barony-bin ${EOS_LIBRARIES})
> + endif()
> + if (APPLE)
> + target_link_libraries(barony ${GLUT_LIBRARIES} ${PROJECT_SOURCE_DIR}/libpng16.16.dylib) #Wait...what? if(APPLE) in if(WIN32)? What was I thinking back then, haha.
> +@@ -403,23 +403,23 @@ if (GAME_ENABLED)
> + find_path(EXECINFO_INC NAMES execinfo.h)
> + find_library(EXECINFO_LIB NAMES execinfo)
> + include_directories(${EXECINFO_INC})
> +- target_link_libraries(barony ${EXECINFO_LIB})
> ++ target_link_libraries(barony-bin ${EXECINFO_LIB})
> + endif()
> + endif()
> +- target_link_libraries(barony ${OPENGL_LIBRARIES})
> +- target_link_libraries(barony ${THREADS_LIBRARIES})
> +- target_link_libraries(barony -lm)
> ++ target_link_libraries(barony-bin ${OPENGL_LIBRARIES})
> ++ target_link_libraries(barony-bin ${THREADS_LIBRARIES})
> ++ target_link_libraries(barony-bin -lm)
> + if (NOT CMAKE_SYSTEM_NAME MATCHES "Haiku")
> +- target_link_libraries(barony -lc)
> ++ target_link_libraries(barony-bin -lc)
> else()
> -- target_link_libraries(barony ${VORBISFILE_LIBRARY} ${OGG_LIBRARY})
> -+ target_link_libraries(barony-bin ${VORBISFILE_LIBRARY} ${OGG_LIBRARY})
> + target_link_libraries(barony -lroot)
> endif()
> - endif()
> -
> -@@ -372,7 +372,7 @@ if (NOT APPLE AND UNIX)
> + if( NOT WIN32 AND NOT APPLE)
> + #Remember, Windows and Mac aren't using find_package for FMOD and PNG.
> +- target_link_libraries(barony ${PNG_LIBRARY})
> +- target_link_libraries(barony ${PHYSFS_LIBRARY})
> ++ target_link_libraries(barony-bin ${PNG_LIBRARY})
> ++ target_link_libraries(barony-bin ${PHYSFS_LIBRARY})
> + if (FMOD_FOUND)
> +- target_link_libraries(barony ${FMOD_LIBRARY})
> ++ target_link_libraries(barony-bin ${FMOD_LIBRARY})
> + endif()
> + endif()
> + if (APPLE)
> +@@ -436,14 +436,14 @@ if (GAME_ENABLED)
> + target_link_libraries(barony -lfmodex) #Finally manually link fmod for mac.
> + endif()
> + endif(APPLE)
> +- target_link_libraries(barony ${EXTRA_LIBS}) #Apple needs this for OpenGL to work.
> ++ target_link_libraries(barony-bin ${EXTRA_LIBS}) #Apple needs this for OpenGL to work.
> +
> + if (OPENAL)
> +- target_link_libraries(barony ${OPENAL_LIBRARY})
> ++ target_link_libraries(barony-bin ${OPENAL_LIBRARY})
> + if(TREMOR_ENABLED)
> +- target_link_libraries(barony ${TREMOR_LIBRARY})
> ++ target_link_libraries(barony-bin ${TREMOR_LIBRARY})
> + else()
> +- target_link_libraries(barony ${VORBISFILE_LIBRARY} ${OGG_LIBRARY})
> ++ target_link_libraries(barony-bin ${VORBISFILE_LIBRARY} ${OGG_LIBRARY})
> + endif()
> endif()
> + endif(GAME_ENABLED)
> +@@ -458,7 +458,7 @@ if (NOT APPLE AND UNIX)
> message(STATUS "Base data directory ${BASE_DATA_DIR}")
>
> -- install(TARGETS barony
> -+ install(TARGETS barony-bin
> - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
> - COMPONENT Runtime
> - )
> -@@ -457,7 +457,7 @@ if (NOT APPLE AND UNIX)
> - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
> - )
> + if (GAME_ENABLED)
> +- install(TARGETS barony
> ++ install(TARGETS barony-bin
> + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
> + COMPONENT Runtime
> + )
> +@@ -561,7 +561,7 @@ if (NOT APPLE AND UNIX)
> + )
> + endif()
>
> - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lang DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/barony)
> + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lang DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/barony)
> Index: patches/patch-cmake_Modules_FindThreads_cmake
> ===================================================================
> RCS file: patches/patch-cmake_Modules_FindThreads_cmake
> diff -N patches/patch-cmake_Modules_FindThreads_cmake
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-cmake_Modules_FindThreads_cmake 3 Oct 2020 21:08:18 -0000
> @@ -0,0 +1,19 @@
> +$OpenBSD$
> +
> +OpenBSD threads lib is pthread
> +
> +Index: cmake/Modules/FindThreads.cmake
> +--- cmake/Modules/FindThreads.cmake.orig
> ++++ cmake/Modules/FindThreads.cmake
> +@@ -26,9 +26,9 @@ ELSE(CMAKE_HAVE_SPROC_H)
> + SET(CMAKE_HAVE_THREADS_LIBRARY)
> + IF(NOT THREADS_HAVE_PTHREAD_ARG)
> + # Do we have -lpthreads
> +- CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
> ++ CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
> + IF(CMAKE_HAVE_PTHREADS_CREATE)
> +- SET(CMAKE_THREAD_LIBS_INIT "-lpthreads")
> ++ SET(CMAKE_THREAD_LIBS_INIT "-lpthread")
> + SET(CMAKE_HAVE_THREADS_LIBRARY 1)
> + ENDIF(CMAKE_HAVE_PTHREADS_CREATE)
> + # Ok, how about -lpthread
>
>

No comments:

Post a Comment