Skip to content

Commit ba35dec

Browse files
authored
Scene graph refactor and null client patch (Segs#635)
* Fix null client patch build. * Extend the runtime. Add a templatized Handle for handle-based storage. Split up prefab/model/axisalignedbox from scene graph namespace the scene graph parts. * Architectural changes: * Handlers/Services now have a separate _interface libraries that users of given service can be linked with, to provide access to all message classes given service supports. * introduced 2 new cmake macros to help with adding new handlers: ** `add_messages_library` which scans current directory for headers with message macros and creates _interface library ** `add_handler` creates a handler library from provided source files, and marks it to link with a correspondng _interface library * NetStructures library was merged with GameData Runtime data and scene graph changes: * Scene graph now learned to properly store most of the information provided by the loaded files. * Many parts of scene graph use handle based storage. * Runtime data now also knows how to handle models/textures MapViewer changes: * updated to latest lutefisk3d * no longer uses a custom scene graph loader. * makes a better use of cached graph nodes. Misc changes: * Common needs ACE as a full blown dependency. * All _interface classes in turn, depend on Common * Visual studio project view has all targets in proper folders * Fix output directory paths * SEGSEventFactory learned how to pack/unpack events to a std::stream.
1 parent 0bdbf2b commit ba35dec

File tree

582 files changed

+5312
-4782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

582 files changed

+5312
-4782
lines changed

3rd_party/CMakeLists.txt

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
link_directories(${ThirdParty_Install_Dir}/lib)
22

33
include(ExternalProject_CEREAL.cmake)
4+
if(BUILD_COX_MAP_VIEWER)
5+
# add_subdirectory(Lute)
6+
include(ExternalProject_Lutefisk3D.cmake)
7+
else()
8+
endif()
49
include(ExternalProject_ACE.cmake)
510
if(MINGW) # ERICEDIT: If the OS is Windows:
611
add_custom_target( # ERICEDIT: Add a target that depends on authserver.
712
libace ALL
8-
DEPENDS ${EXECUTABLE_OUTPUT_PATH}/authserver.exe
13+
DEPENDS ace_IMP
914
)
1015
add_custom_command( # ERICEDIT: Copy over libACE.dll to the output directory.
1116
TARGET libace
1217
POST_BUILD
13-
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ace_LIBRARY_SHARED} ${EXECUTABLE_OUTPUT_PATH}
18+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ace_LIBRARY_SHARED} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
1419
)
1520
endif()
16-
if(BUILD_COX_MAP_VIEWER)
17-
include(ExternalProject_Lutefisk3D.cmake)
18-
endif()
1921
########################################################################################
2022
# Optional components
2123
########################################################################################

3rd_party/ExternalProject_Lutefisk3D.cmake

+73-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,75 @@
1-
libname(lutefisk3d Lutefisk3D)
2-
ExternalProject_Add(
3-
l3d_BUILD
4-
GIT_REPOSITORY https://github.com/Lutefisk3D/lutefisk3d
5-
GIT_SHALLOW 1
6-
UPDATE_COMMAND ""
7-
INSTALL_DIR ${ThirdParty_Install_Dir}
8-
CMAKE_ARGS -DQt5_DIR:PATH=${Qt5_DIR} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DCMAKE_STAGING_PREFIX:PATH=${ThirdParty_Install_Dir} -DCMAKE_INSTALL_PREFIX:PATH=${ThirdParty_Install_Dir}
9-
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
10-
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
11-
BUILD_BYPRODUCTS ${lutefisk3d_LIBRARY_SHARED} ${lutefisk3d_LIBRARY_IMP}
12-
)
13-
ADD_LIBRARY(lutefisk3d_IMP SHARED IMPORTED GLOBAL)
14-
add_dependencies(lutefisk3d_IMP l3d_BUILD)
15-
#set_shared_lib_properties(lutefisk3d)
16-
SET_PROPERTY(TARGET lutefisk3d_IMP APPEND PROPERTY IMPORTED_LOCATION ${lutefisk3d_LIBRARY_SHARED} )
17-
SET_PROPERTY(TARGET lutefisk3d_IMP APPEND PROPERTY IMPORTED_LOCATION_DEBUG ${lutefisk3d_LIBRARY_SHARED} )
18-
SET_PROPERTY(TARGET lutefisk3d_IMP APPEND PROPERTY IMPORTED_LOCATION_RELEASE ${lutefisk3d_LIBRARY_SHARED} )
19-
SET_PROPERTY(TARGET lutefisk3d_IMP APPEND PROPERTY IMPORTED_IMPLIB ${lutefisk3d_LIBRARY_IMP} )
20-
SET_PROPERTY(TARGET lutefisk3d_IMP APPEND PROPERTY IMPORTED_IMPLIB_RELEASE ${lutefisk3d_LIBRARY_IMP} )
21-
if(MSVC)
22-
SET_PROPERTY(TARGET lutefisk3d_IMP APPEND PROPERTY IMPORTED_IMPLIB_DEBUG ${ThirdParty_Install_Dir}/lib/Lutefisk3D_Debug.lib )
1+
if(FALSE)
2+
set(LUTEFISK3D_NETWORK OFF) # don't need it, and it doesn't compile anyway :)
3+
add_subdirectory(Lute)
234
else()
24-
SET_PROPERTY(TARGET lutefisk3d_IMP APPEND PROPERTY IMPORTED_IMPLIB_DEBUG ${lutefisk3d_LIBRARY_IMP_D} )
5+
#NOTE: by default lutefisk builds in RelWithDebInfo
6+
# for our use case this seems the most optimal build type.
7+
libname(lutefisk3d Lutefisk3D)
8+
# add the main options for lutefisk,
9+
# NOTE: this only works when Lutefisk is aleady checked-out submodule
10+
# this will likely happen, but not just yet.
11+
#include(${CMAKE_CURRENT_SOURCE_DIR}/Lute/CMake/LutefiskOptions.cmake)
12+
set(LUTEFISK3D_NETWORK OFF) # don't need it, and it doesn't compile anyway :)
13+
14+
set(lutefisk_cmake_options
15+
-DQt5_DIR:PATH=${Qt5_DIR}
16+
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
17+
-DCMAKE_STAGING_PREFIX:PATH=${ThirdParty_Install_Dir}
18+
-DCMAKE_INSTALL_PREFIX:PATH=${ThirdParty_Install_Dir}
19+
)
20+
if(MINGW)
21+
set(IMPLIB_PATH ${ThirdParty_Install_Dir}/lib/libLutefisk3D_RelWithDebugInfo.dll.a )
22+
endif()
23+
# forward LUTEFISK3D_* options to the external project build.
24+
get_cmake_property(__cmake_variables VARIABLES)
25+
foreach (var ${__cmake_variables})
26+
if ("${var}" MATCHES "^LUTEFISK3D_")
27+
set(lutefisk_cmake_options ${lutefisk_cmake_options} -D${var}:BOOL=${${var}})
28+
endif ()
29+
endforeach()
30+
31+
ExternalProject_Add(
32+
l3d_BUILD
33+
# SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Lute
34+
GIT_REPOSITORY https://github.com/Lutefisk3D/lutefisk3d
35+
GIT_SHALLOW 1
36+
UPDATE_COMMAND ""
37+
INSTALL_DIR ${ThirdParty_Install_Dir}
38+
CMAKE_ARGS ${lutefisk_cmake_options}
39+
CMAKE_GENERATOR "${CMAKE_GENERATOR}"
40+
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
41+
BUILD_BYPRODUCTS ${lutefisk3d_LIBRARY_SHARED} ${lutefisk3d_LIBRARY_IMP} ${IMPLIB_PATH}
42+
EXCLUDE_FROM_ALL ON # don't build this when build-all is requested ?
43+
)
44+
add_library(Lutefisk3D SHARED IMPORTED GLOBAL)
45+
target_include_directories(Lutefisk3D INTERFACE ${ThirdParty_Install_Dir}/include)
46+
add_dependencies(Lutefisk3D l3d_BUILD)
47+
#set_shared_lib_properties(lutefisk3d)
48+
set_property(TARGET Lutefisk3D APPEND PROPERTY IMPORTED_LOCATION ${lutefisk3d_LIBRARY_SHARED} )
49+
set_property(TARGET Lutefisk3D APPEND PROPERTY IMPORTED_LOCATION_DEBUG ${lutefisk3d_LIBRARY_SHARED} )
50+
set_property(TARGET Lutefisk3D APPEND PROPERTY IMPORTED_LOCATION_RELEASE ${lutefisk3d_LIBRARY_SHARED} )
51+
52+
# add lutefisk defines
53+
foreach (var ${__cmake_variables})
54+
if ("${var}" MATCHES "^LUTEFISK3D_")
55+
if ("${${var}}")
56+
target_compile_definitions(Lutefisk3D INTERFACE -D${var})
57+
endif ()
58+
endif ()
59+
endforeach()
60+
61+
if(MINGW)
62+
set_property(TARGET Lutefisk3D PROPERTY IMPORTED_IMPLIB ${IMPLIB_PATH} )
63+
set_property(TARGET Lutefisk3D PROPERTY IMPORTED_IMPLIB_DEBUG ${IMPLIB_PATH} )
64+
set_property(TARGET Lutefisk3D PROPERTY IMPORTED_IMPLIB_RELWITHDEBINFO ${IMPLIB_PATH} )
65+
else()
66+
set_property(TARGET Lutefisk3D APPEND PROPERTY IMPORTED_IMPLIB ${lutefisk3d_LIBRARY_IMP} )
67+
set_property(TARGET Lutefisk3D APPEND PROPERTY IMPORTED_IMPLIB_RELEASE ${lutefisk3d_LIBRARY_IMP} )
68+
if(MSVC)
69+
set_property(TARGET Lutefisk3D APPEND PROPERTY IMPORTED_IMPLIB_DEBUG ${lutefisk3d_LIBRARY_IMP} )
70+
else()
71+
set_property(TARGET Lutefisk3D APPEND PROPERTY IMPORTED_IMPLIB_DEBUG ${lutefisk3d_LIBRARY_IMP} )
72+
endif()
73+
endif()
74+
#set_property(TARGET Lutefisk3D APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS ACE_HAS_DLL=1)
2575
endif()
26-
#set_property(TARGET lutefisk3d_IMP APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS ACE_HAS_DLL=1)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

CMakeLists.txt

+61-59
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CMAKE_MINIMUM_REQUIRED(VERSION 3.4)
1+
CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
22
PROJECT(SEGS)
33

44
set(CMAKE_CXX_STANDARD 14)
@@ -7,17 +7,22 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
77
IF(MSVC)
88
add_definitions( -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -DNOMINMAX -D_USE_MATH_DEFINES)
99
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
10-
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wuseless-cast -std=c++14" )
10+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wuseless-cast -std=c++14 -Wno-unknown-warning-option")
1111
ELSEIF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
12-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wuseless-cast -std=c++14 -Wno-nested-anon-types -Wno-gnu-anonymous-struct -Wno-gnu-zero-variadic-macro-arguments")
12+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wuseless-cast -std=c++14 -Wno-nested-anon-types -Wno-gnu-anonymous-struct -Wno-gnu-zero-variadic-macro-arguments -Wno-unknown-warning-option")
1313
endif()
1414
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
15+
set(AUTOGEN_TARGETS_FOLDER ON)
1516

1617
add_definitions(-D__STDC_FORMAT_MACROS)
1718

1819
SET(MAIN_INCLUDE_PATH ${PROJECT_SOURCE_DIR}/3rd_party/include CACHE PATH "Includes")
1920
SET(MAIN_LIB_PATH ${PROJECT_SOURCE_DIR}/3rd_party/lib CACHE PATH "Libraries")
20-
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/out) # ERICEDIT: Changed the output directory to the build directory rather than source.
21+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
22+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)
23+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/out)
24+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)
25+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/out)
2126
SET(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/out)
2227
SET(CMAKE_INCLUDE_PATH ${MAIN_INCLUDE_PATH})
2328
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeScripts;${CMAKE_MODULE_PATH})
@@ -35,53 +40,11 @@ find_package(Threads REQUIRED)
3540
include(3rdparty_support)
3641
set(ThirdParty_Install_Dir ${CMAKE_BINARY_DIR}/3rd_party/built) # ERICEDIT: Changed to CMAKE_BINARY_DIR so that this variable always points to the top level of the build directory.
3742
add_subdirectory(3rd_party)
38-
add_definitions(-DACE_HAS_DLL=1) # TODO: this should be set by per-target add_definitions
3943
link_directories(${PROJECT_SOURCE_DIR}/lib) # ERICEDIT: Changed to lowercase.
4044

41-
SET(QT_MISSING True)
42-
# msvc only; mingw will need different logic
43-
IF(MSVC)
44-
# look for user-registry pointing to qtcreator
45-
GET_FILENAME_COMPONENT(QT_BIN [HKEY_CURRENT_USER\\Software\\Classes\\Applications\\QtProject.QtCreator.cpp\\shell\\Open\\Command] PATH)
46-
if(${MSVC_VERSION} VERSION_LESS "1910")
47-
MESSAGE(FATAL_ERROR "SEGS requires visual studio 2017 to build")
48-
endif()
49-
50-
# get root path so we can search for 5.3, 5.4, 5.5, etc
51-
STRING(REPLACE "/Tools" ";" QT_BIN "${QT_BIN}")
52-
LIST(GET QT_BIN 0 QT_BIN)
53-
FILE(GLOB QT_VERSIONS "${QT_BIN}/5.*")
54-
LIST(SORT QT_VERSIONS)
55-
56-
# assume the latest version will be last alphabetically
57-
LIST(REVERSE QT_VERSIONS)
58-
59-
LIST(GET QT_VERSIONS 0 QT_VERSION)
60-
61-
# fix any double slashes which seem to be common
62-
STRING(REPLACE "//" "/" QT_VERSION "${QT_VERSION}")
63-
64-
# we only support 2017, and qt5 uses vs2015 files for 32 bit build
65-
SET(QT_MSVC "2015")
66-
# check for 64-bit os
67-
# may need to be removed for older compilers as it wasn't always offered
68-
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
69-
SET(QT_MSVC "2017_64")
70-
endif()
71-
72-
SET(QT_PATH "${QT_VERSION}/msvc${QT_MSVC}")
73-
SET(QT_MISSING False)
74-
file(TO_NATIVE_PATH "${QT_PATH}/bin" QT_BIN_DIR_WINDOWS)
75-
set(CMAKE_MSVCIDE_RUN_PATH "${QT_BIN_DIR_WINDOWS}" CACHE STATIC "MSVC IDE Run path" FORCE)
76-
ENDIF()
77-
78-
# use Qt_DIR approach so you can find Qt after cmake has been invoked
79-
IF(NOT QT_MISSING)
80-
MESSAGE("-- Qt found: ${QT_PATH}")
81-
SET(Qt5_DIR "${QT_PATH}/lib/cmake/Qt5/")
82-
SET(Qt5Test_DIR "${QT_PATH}/lib/cmake/Qt5Test")
83-
ENDIF()
45+
include(LocateQt5)
8446
find_package(Qt5 COMPONENTS Core Sql REQUIRED)
47+
8548
if(ENABLE_TESTS)
8649
enable_testing()
8750
find_package(Qt5 COMPONENTS Test REQUIRED)
@@ -96,6 +59,29 @@ if(ENABLE_TESTS)
9659
)
9760
endmacro()
9861
endif()
62+
63+
link_directories(${ThirdParty_Install_Dir}/lib)
64+
include_directories(SYSTEM ${ThirdParty_Install_Dir}/include)
65+
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/3rd_party)
66+
include_directories(${PROJECT_SOURCE_DIR}/include)
67+
68+
include_directories(Components)
69+
70+
# this has to be visited before scan_event_types macro below has been used
71+
add_subdirectory(Utilities)
72+
# this function is here to solve the env paths issue
73+
function(to_path_list var path1)
74+
if("${CMAKE_HOST_SYSTEM}" MATCHES ".*Windows.*")
75+
set(sep "\\;")
76+
else()
77+
set(sep ":")
78+
endif()
79+
set(result "${path1}") # First element doesn't require separator at all...
80+
foreach(path ${ARGN})
81+
set(result "${result}${sep}${path}") # .. but other elements do.
82+
endforeach()
83+
set(${var} "${result}" PARENT_SCOPE)
84+
endfunction()
9985
##############################################
10086
# Event registration support functionality
10187
macro(scan_event_types group) # followed by a list of directories to scan
@@ -105,9 +91,10 @@ macro(scan_event_types group) # followed by a list of directories to scan
10591
file(GLOB headers ${path}/*.h)
10692
list(APPEND all_headers ${headers})
10793
endforeach()
108-
94+
to_path_list(path_with_qt5 $ENV{PATH} ${Qt5_BIN_DIR} )
95+
# for event_gen we first add qt5 binary path to allow it to run during build.
10996
add_custom_command(
110-
COMMAND event_gen scan_events ${group} ${CMAKE_CURRENT_BINARY_DIR}/ ${ARGN}
97+
COMMAND ${CMAKE_COMMAND} -E env "PATH=${path_with_qt5}" $<SHELL_PATH:$<TARGET_FILE:event_gen>> scan_events ${group} ${CMAKE_CURRENT_BINARY_DIR}/ ${ARGN}
11198
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${group}.gen.cpp
11299
DEPENDS event_gen ${all_headers}
113100
COMMENT "Generating ${group} implementation source"
@@ -117,19 +104,34 @@ macro(add_event_sources group tgt_var)
117104
list(APPEND ${tgt_var} ${CMAKE_CURRENT_BINARY_DIR}/${group}.gen.cpp)
118105
message("adding ${group} to sources")
119106
endmacro()
120-
##############################################
121-
122-
link_directories(${ThirdParty_Install_Dir}/lib)
123-
include_directories(SYSTEM ${ThirdParty_Install_Dir}/include)
124-
include_directories(${PROJECT_SOURCE_DIR}/include)
107+
macro(add_messages_library name )
108+
#find handler's events
109+
scan_event_types(${name}Events ${CMAKE_CURRENT_SOURCE_DIR})
110+
add_event_sources(${name}Events ${name}_SOURCES)
111+
add_library(${name}_interface STATIC ${${name}_SOURCES} ${ARGN})
112+
# allow all headers to refer to events by their dir/name.h
113+
target_include_directories(${name}_interface PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
114+
target_link_libraries(${name}_interface PUBLIC Qt5::Core)
115+
# all interfaces use stuff from Common, so should depend/link to it
116+
target_link_libraries(${name}_interface PUBLIC SEGS_Components)
117+
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${ARGN})
118+
set_target_properties (${name}_interface PROPERTIES
119+
FOLDER Projects/CoX/Common/Messages
120+
)
121+
endmacro()
125122

126-
include_directories(Components)
123+
macro(add_handler name)
124+
# TODO: consider add_subdirectory(../../Common/Messages/${name}) to force existence/building of interface lib
125+
# add the implementation library
126+
add_library(${name} STATIC ${ARGN})
127+
target_link_libraries(${name} PUBLIC ${name}_interface)
128+
endmacro()
129+
##############################################
127130

128131
add_subdirectory(Components)
129-
add_subdirectory(Utilities)
130132
add_subdirectory(Projects)
131133

132-
file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/data)
134+
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data)
133135

134136
set(MAPNAMES
135137
City_00_01
@@ -150,5 +152,5 @@ set(MAPNAMES
150152
Trial_05_01
151153
)
152154
foreach(MAPDIR ${MAPNAMES})
153-
file(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/DefaultMapInstances/${MAPDIR})
155+
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/DefaultMapInstances/${MAPDIR})
154156
endforeach(MAPDIR)

CMakeScripts/LocateQt5.cmake

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
SET(QT_MISSING True)
2+
# msvc only; mingw will need different logic
3+
IF(MSVC)
4+
# look for user-registry pointing to qtcreator
5+
GET_FILENAME_COMPONENT(QT_BIN [HKEY_CURRENT_USER\\Software\\Classes\\Applications\\QtProject.QtCreator.cpp\\shell\\Open\\Command] PATH)
6+
if(${MSVC_VERSION} VERSION_LESS "1910")
7+
MESSAGE(FATAL_ERROR "SEGS requires visual studio 2017 to build")
8+
endif()
9+
10+
# get root path so we can search for 5.3, 5.4, 5.5, etc
11+
STRING(REPLACE "/Tools" ";" QT_BIN "${QT_BIN}")
12+
LIST(GET QT_BIN 0 QT_BIN)
13+
FILE(GLOB QT_VERSIONS "${QT_BIN}/5.*")
14+
LIST(SORT QT_VERSIONS)
15+
16+
# assume the latest version will be last alphabetically
17+
LIST(REVERSE QT_VERSIONS)
18+
19+
LIST(GET QT_VERSIONS 0 QT_VERSION)
20+
21+
# fix any double slashes which seem to be common
22+
STRING(REPLACE "//" "/" QT_VERSION "${QT_VERSION}")
23+
24+
# we only support 2017, and qt5 uses vs2015 files for 32 bit build
25+
SET(QT_MSVC "2015")
26+
# check for 64-bit os
27+
# may need to be removed for older compilers as it wasn't always offered
28+
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
29+
SET(QT_MSVC "2017_64")
30+
endif()
31+
32+
SET(QT_PATH "${QT_VERSION}/msvc${QT_MSVC}")
33+
SET(QT_MISSING False)
34+
file(TO_NATIVE_PATH "${QT_PATH}/bin" QT_BIN_DIR_WINDOWS)
35+
set(CMAKE_MSVCIDE_RUN_PATH "${QT_BIN_DIR_WINDOWS}" CACHE STATIC "MSVC IDE Run path" FORCE)
36+
ENDIF()
37+
38+
MACRO(TO_NATIVE_PATH PATH OUT)
39+
FILE(TO_NATIVE_PATH "${PATH}" "${OUT}")
40+
IF(MINGW)
41+
STRING(REPLACE "/" "\\" "${OUT}" "${${OUT}}")
42+
ENDIF(MINGW)
43+
ENDMACRO(TO_NATIVE_PATH)
44+
# use Qt_DIR approach so you can find Qt after cmake has been invoked
45+
IF(NOT QT_MISSING)
46+
MESSAGE("-- Qt found: ${QT_PATH}")
47+
SET(Qt5_DIR "${QT_PATH}/lib/cmake/Qt5/")
48+
SET(Qt5Test_DIR "${QT_PATH}/lib/cmake/Qt5Test")
49+
ENDIF()
50+
find_package(Qt5 REQUIRED COMPONENTS Core)
51+
get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION)
52+
get_filename_component(Qt5_BIN_DIR "${_qmake_executable}" DIRECTORY)
53+
TO_NATIVE_PATH("${Qt5_BIN_DIR}" Qt5_BIN_DIR)
54+

Components/BitStream.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ void BitStream::StoreString(const char *str)
236236
m_write_off += idx;
237237
}
238238

239+
void BitStream::StoreString(const QByteArray &str)
240+
{
241+
StoreString(str.constData());
242+
}
243+
239244
void BitStream::StoreString(const QString &str)
240245
{
241246
StoreString(qPrintable(str));
@@ -367,10 +372,10 @@ int64_t BitStream::Get64Bits()
367372
return result;
368373
}
369374

370-
size_t BitStream::GetAvailSize() const
375+
uint32_t BitStream::GetAvailSize() const
371376
{
372377
int64_t res = int64_t(m_size)- int64_t(m_write_off)-(m_write_bit_off!=0);
373-
return size_t(std::max<int64_t>(0,res));
378+
return uint32_t(std::max<int64_t>(0,res));
374379
}
375380
/************************************************************************
376381
Function: GetFloat/GetFloatWithDebugInfo()

0 commit comments

Comments
 (0)