$OpenBSD: patch-CMakeLists_txt,v 1.2 2018/10/01 12:00:12 solene Exp $

Remove hardcoded -O3
Rename binary to barony-bin because we are invoking the
game via a wrapper script, which is named barony.

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++")
 else()
-add_executable(barony ${GAME_SOURCES})
+add_executable(barony-bin ${GAME_SOURCES})
 endif()
 
 if(WIN32)
@@ -309,9 +309,9 @@ if(WIN32)
 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})
   else()
-    target_link_libraries(barony ${VORBISFILE_LIBRARY} ${OGG_LIBRARY})
+    target_link_libraries(barony-bin ${VORBISFILE_LIBRARY} ${OGG_LIBRARY})
   endif()
 endif()
 
@@ -372,7 +372,7 @@ if (NOT APPLE AND UNIX)
   endif()
   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
   )
 
-  install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lang DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/barony)
+  install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lang DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/barony)
 
   if (EXISTS books)
     install(DIRECTORY 
