diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000000..e2f2c79d4c9 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,86 @@ +cmake_minimum_required(VERSION 3.11) +project(ioquake3 VERSION 1.36 LANGUAGES C ASM) + +include(CheckSymbolExists) +include(CheckCCompilerFlag) + +set(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(CODE_DIR ${ROOT_DIR}/code) +set(LIBS_DIR ${ROOT_DIR}/libs) + +set(ENGINE_BINARY_DIR ${CMAKE_BINARY_DIR}) + +option(DEFAULT_BASEDIR "extra path to search for baseq3 and such" "") +option(BUILD_CLIENT "build the 'ioquake3' client binary" ON) +option(BUILD_SERVER "build the 'ioq3ded' server binary" ON) +option(BUILD_RENDERER_OPENGL2 "" ON) +option(BUILD_AUTOUPDATER "DON'T build unless you mean to!" OFF) +option(BUILD_STANDALONE "build binaries suited for stand-alone games" OFF) + +set(SERVERBIN "ioq3ded" CACHE STRING "server binary") +set(CLIENTBIN "ioquake3" CACHE STRING "client binary") + +option(USE_RENDERER_DLOPEN "build and use the renderer in a library" ON) +option(USE_OPENAL_DLOPEN "link with OpenAL at runtime" ON) +option(USE_CURL_DLOPEN "link with libcurl at runtime" ON) +option(USE_VOIP "enable built-in VoIP support" ON) +option(USE_MUMBLE "enable Mumble support" ON) + +if (MSVC) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO") + # 4244 conversion from 'float' to 'int', possible loss of data + # 4305 truncation from 'double' to 'float' + # 4820 padding + # 5045 spectre instruction + # 4668 unknown macro definition + # 4061 explicit switch case enum mention + # 4242 possible loss of data (convert int to short) + # 4464 relative include path + # 4619 warning id is not available + # 4245 return signed/unsigned conflict + # 4100 unreferenced formal parameter + # 4255 invalid function prototype - missing void + # 4389 comparison signed/unsigned + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4267 /wd4244 /wd4305 /wd4820 /wd5045 /wd4668 /wd4061 /wd4242 /wd4464 /wd4619 /wd4245 /wd4100 /wd4255 /wd4389") + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) +endif() + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +if (APPLE) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9) + add_compile_definitions(MAC_OS_X_VERSION_MIN_REQUIRED=1070) +endif() + +set(ARCH_STRING x86) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(ARCH_STRING x86_64) +endif() + +add_compile_definitions(PRODUCT_VERSION="${CMAKE_PROJECT_VERSION}" ARCH_STRING="${ARCH_STRING}") + +if (BUILD_STANDALONE) + add_compile_definitions(STANDALONE) +endif() + +macro(check_compiler_flag flag) + string(REGEX REPLACE "[-=+]" "_" _flag ${flag}) + string(TOUPPER ${_flag} _flagfinal) + check_c_compiler_flag("${flag}" COMPILER_SUPPORTS_${_flagfinal}) + if (COMPILER_SUPPORTS_${_flagfinal}) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") + endif() +endmacro() + +check_compiler_flag(-Wformat=2) +check_compiler_flag(-Wno-format-zero-length) +check_compiler_flag(-Wformat-security) +check_compiler_flag(-Wno-format-nonliteral) +check_compiler_flag(-Wstrict-aliasing=2) +check_compiler_flag(-Wmissing-format-attribute) +check_compiler_flag(-Wdisabled-optimization) +check_compiler_flag(-Werror-implicit-function-declaration) + +add_subdirectory(code) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt new file mode 100644 index 00000000000..cfcfb8c7a01 --- /dev/null +++ b/code/CMakeLists.txt @@ -0,0 +1,317 @@ +add_subdirectory(AL) +add_subdirectory(curl-7.54.0) +add_subdirectory(jpeg-8c) +add_subdirectory(libogg-1.3.3) +add_subdirectory(libvorbis-1.3.6) +add_subdirectory(opus-1.2.1) +add_subdirectory(opusfile-0.9) +add_subdirectory(zlib) +add_subdirectory(SDL2) + +check_compiler_flag(-Wall) +check_compiler_flag(-Wextra) +check_compiler_flag(-Wno-unused-parameter) +check_compiler_flag(-Wno-sign-compare) + +set(QCOMMON_COLLISION_SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/cm_load.c + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/cm_local.h + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/cm_patch.c + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/cm_patch.h + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/cm_polylib.c + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/cm_polylib.h + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/cm_public.h + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/cm_test.c + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/cm_trace.c +) +set(QCOMMON_VM_SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/vm.c + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/vm_interpreted.c + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/vm_local.h + ${CMAKE_CURRENT_SOURCE_DIR}/qcommon/vm_x86.c +) + +find_program(GDB_EXECUTABLE gdb) +find_program(LLDB_EXECUTABLE lldb) +if (GDB_EXECUTABLE) + set(DEBUGGER ${GDB_EXECUTABLE} CACHE STRING "Which debugger should be used") +elseif (LLDB_EXECUTABLE) + set(DEBUGGER ${LLDB_EXECUTABLE} CACHE STRING "Which debugger should be used") +else() + set(DEBUGGER "unknown" CACHE STRING "Which debugger should be used") + message(STATUS "No debugger (gdb or lldb) was found") +endif() +set_property(CACHE DEBUGGER PROPERTY STRINGS gdb lldb) + +function(add_debuggger TARGET) + if (${DEBUGGER} MATCHES "gdb") + add_custom_target(${TARGET}-debug) + add_custom_command(TARGET ${TARGET}-debug + COMMAND ${GDB_EXECUTABLE} -ex run --args $ + COMMENT "Starting debugger session for ${TARGET}" + USES_TERMINAL + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + DEPENDS ${TARGET} + ) + elseif (${DEBUGGER} MATCHES "lldb") + add_custom_target(${TARGET}-debug) + add_custom_command(TARGET ${TARGET}-debug + COMMAND CG_CONTEXT_SHOW_BACKTRACE=1 ${LLDB_EXECUTABLE} -b -o run $ + COMMENT "Starting debugger session for ${TARGET}" + USES_TERMINAL + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + DEPENDS ${TARGET} + ) + endif() +endfunction() + +function(q3_add_library) + set(_OPTIONS_ARGS) + set(_ONE_VALUE_ARGS TARGET GAME_NAME) + set(_MULTI_VALUE_ARGS SRCS) + + cmake_parse_arguments(_LIB "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) + + set(OUTPUTNAME "${_LIB_TARGET}_${ARCH_STRING}") + set(LIB_BINARY_DIR "${ENGINE_BINARY_DIR}") + + if (_LIB_GAME_NAME) + set(LIB_TARGET ${_LIB_GAME_NAME}-${_LIB_TARGET}) + set(LIB_BINARY_DIR "${CMAKE_BINARY_DIR}/${_LIB_GAME_NAME}") + else() + set(LIB_TARGET ${_LIB_TARGET}) + endif() + + add_library(${LIB_TARGET} SHARED ${_LIB_SRCS}) + + if (_LIB_GAME_NAME) + set_target_properties(${LIB_TARGET} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/${CMAKE_PROJECT_NAME}/${_LIB_GAME_NAME}) + else() + set_target_properties(${LIB_TARGET} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/${CMAKE_PROJECT_NAME}) + endif() + + set_target_properties(${LIB_TARGET} PROPERTIES PREFIX "") + set_target_properties(${LIB_TARGET} PROPERTIES OUTPUT_NAME "${OUTPUTNAME}") + set_target_properties(${LIB_TARGET} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${LIB_BINARY_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${LIB_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY "${LIB_BINARY_DIR}" + ) + foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) + set_target_properties(${LIB_TARGET} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${LIB_BINARY_DIR}" + LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${LIB_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${LIB_BINARY_DIR}" + ) + endforeach() +endfunction() + +function(q3_add_executable) + set(_OPTIONS_ARGS WINDOWED) + set(_ONE_VALUE_ARGS TARGET) + set(_MULTI_VALUE_ARGS SRCS) + + cmake_parse_arguments(_EXE "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} ) + + if (_EXE_WINDOWED) + if (WIN32) + add_executable(${_EXE_TARGET} WIN32 ${SRCS}) + if (MSVC) + set_target_properties(${_EXE_TARGET} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") + endif() + elseif(APPLE) + add_executable(${_EXE_TARGET} MACOSX_BUNDLE ${SRCS}) + else() + add_executable(${_EXE_TARGET} ${SRCS}) + endif() + else() + add_executable(${_EXE_TARGET} ${SRCS}) + if (WIN32) + if (MSVC) + set_target_properties(${_EXE_TARGET} PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE") + endif() + endif() + endif() + + set(OUTPUTNAME "${_EXE_TARGET}.${ARCH_STRING}") + set_target_properties(${_EXE_TARGET} PROPERTIES OUTPUT_NAME "${OUTPUTNAME}") + set_target_properties(${_EXE_TARGET} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${ENGINE_BINARY_DIR}" + LIBRARY_OUTPUT_DIRECTORY "${ENGINE_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY "${ENGINE_BINARY_DIR}" + ) + foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) + set_target_properties(${_EXE_TARGET} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${ENGINE_BINARY_DIR}" + LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${ENGINE_BINARY_DIR}" + RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "${ENGINE_BINARY_DIR}" + ) + endforeach() + + if (APPLE) + set(APPLE_ICONS ${CMAKE_CURRENT_BINARY_DIR}/quake3_flat.icns) + add_custom_command( + OUTPUT ${APPLE_ICONS} + COMMAND iconutil -c icns --output ${APPLE_ICONS} ${ROOT_DIR}/misc/quake3_flat.iconset + ) + set(BUNDLE_RESOURCES ${APPLE_ICONS}) + set_target_properties(${_EXE_TARGET} PROPERTIES RESOURCE "${BUNDLE_RESOURCES}") + target_sources(${_EXE_TARGET} PUBLIC ${BUNDLE_RESOURCES}) + set_source_files_properties(${APPLE_ICONS} PROPERTIES MACOSX_PACKAGE_LOCATION Resources GENERATED TRUE) + + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${ROOT_DIR}/misc/osx/application.plist.in) + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE ON) + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "${CMAKE_PROJECT_NAME}") + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_ICON_FILE "quake3_flat") + #set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_COPYRIGHT "") + #set_target_properties(${_EXE_TARGET} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "YES") + #set_target_properties(${_EXE_TARGET} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer") + #set_target_properties(${_EXE_TARGET} PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY ${CODESIGNIDENTITY}) + #set_target_properties(${_EXE_TARGET} PROPERTIES XCODE_ATTRIBUTE_DEVELOPMENT_TEAM ${DEVELOPMENT_TEAM_ID}) + #set_target_properties(${_EXE_TARGET} PROPERTIES XCODE_ATTRIBUTE_PROVISIONING_PROFILE_SPECIFIER ${PROVISIONING_PROFILE_NAME}) + if (${CMAKE_GENERATOR} STREQUAL "Xcode") + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_EXECUTABLE_NAME \${EXECUTABLE_NAME}) + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_PRODUCT_NAME \${PRODUCT_NAME}) + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME \${PRODUCT_NAME}) + else() + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_PRODUCT_NAME "${CMAKE_PROJECT_NAME}") + set_target_properties(${_EXE_TARGET} PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") + endif() + configure_file(${ROOT_DIR}/misc/osx/copy_dylib.sh.in ${CMAKE_CURRENT_BINARY_DIR}/copy_dylib.sh @ONLY) + add_custom_command(TARGET ${_EXE_TARGET} POST_BUILD COMMAND cd ${CMAKE_BINARY_DIR}\; ${CMAKE_CURRENT_BINARY_DIR}/copy_dylib.sh) + endif() + + add_custom_target(${_EXE_TARGET}-run + COMMAND $ + USES_TERMINAL + DEPENDS ${_EXE_TARGET} + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" + ) + add_debuggger(${_EXE_TARGET}) +endfunction() + +function(add_qvm TARGET_SHORT GAME_NAME) + set(srcfiles ${ARGV}) + string(TOUPPER ${TARGET_SHORT} UPPERTARGET) + set(TARGET ${GAME_NAME}-${TARGET_SHORT}) + set(compileflags "-D${UPPERTARGET}") + set(QVM_SRCS) + foreach(srcfile ${srcfiles}) + get_filename_component(ext ${srcfile} EXT) + if ("${ext}" STREQUAL ".asm") + list(APPEND QVM_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/${srcfile}) + elseif ("${ext}" STREQUAL ".c") + get_filename_component(basename ${srcfile} NAME_WE) + set(q3asm_outfile "${CMAKE_CURRENT_BINARY_DIR}/${basename}.asm") + add_custom_command( + OUTPUT ${q3asm_outfile} + COMMAND q3lcc + ARGS ${compileflags} -o "\"${q3asm_outfile}\"" "\"${CMAKE_CURRENT_SOURCE_DIR}/${srcfile}\"" + DEPENDS q3lcc ${CMAKE_CURRENT_SOURCE_DIR}/${srcfile} + ) + set_source_files_properties(${q3asm_outfile} PROPERTIES GENERATED TRUE) + list(APPEND QVM_SRCS ${q3asm_outfile}) + endif() + endforeach() + + set(QVM_PATH ${GAME_NAME}/vm/${TARGET_SHORT}.qvm) + add_custom_command( + OUTPUT "${ENGINE_BINARY_DIR}/${QVM_PATH}" + COMMAND q3asm + ARGS -o "${ENGINE_BINARY_DIR}/${QVM_PATH}" ${QVM_SRCS} + DEPENDS q3asm ${QVM_SRCS} + ) + add_custom_target(qvm_${TARGET} DEPENDS "${ENGINE_BINARY_DIR}/${QVM_PATH}") + add_dependencies(${TARGET} qvm_${TARGET}) + set_source_files_properties(${QVM_PATH} PROPERTIES GENERATED TRUE) + set_source_files_properties(${QVM_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/${QVM_PATH}) +endfunction() + +function(add_botlib TARGET) + set(BOTLIB_SRCS + ${CODE_DIR}/botlib/be_aas_bspq3.c + ${CODE_DIR}/botlib/be_aas_cluster.c + ${CODE_DIR}/botlib/be_aas_debug.c + ${CODE_DIR}/botlib/be_aas_entity.c + ${CODE_DIR}/botlib/be_aas_file.c + ${CODE_DIR}/botlib/be_aas_main.c + ${CODE_DIR}/botlib/be_aas_move.c + ${CODE_DIR}/botlib/be_aas_optimize.c + ${CODE_DIR}/botlib/be_aas_reach.c + ${CODE_DIR}/botlib/be_aas_route.c + ${CODE_DIR}/botlib/be_aas_routealt.c + ${CODE_DIR}/botlib/be_aas_sample.c + ${CODE_DIR}/botlib/be_ai_char.c + ${CODE_DIR}/botlib/be_ai_chat.c + ${CODE_DIR}/botlib/be_ai_gen.c + ${CODE_DIR}/botlib/be_ai_goal.c + ${CODE_DIR}/botlib/be_ai_move.c + ${CODE_DIR}/botlib/be_ai_weap.c + ${CODE_DIR}/botlib/be_ai_weight.c + ${CODE_DIR}/botlib/be_ea.c + ${CODE_DIR}/botlib/be_interface.c + ${CODE_DIR}/botlib/l_crc.c + ${CODE_DIR}/botlib/l_libvar.c + ${CODE_DIR}/botlib/l_log.c + ${CODE_DIR}/botlib/l_memory.c + ${CODE_DIR}/botlib/l_precomp.c + ${CODE_DIR}/botlib/l_script.c + ${CODE_DIR}/botlib/l_struct.c + ) + target_sources(${TARGET} PRIVATE ${BOTLIB_SRCS}) + #target_include_directories(${TARGET} PRIVATE ${CODE_DIR}/botlib) + foreach(_file ${BOTLIB_SRCS}) + set_property(SOURCE ${_file} APPEND PROPERTY COMPILE_DEFINITIONS BOTLIB) + set_property(SOURCE ${_file} APPEND PROPERTY INCLUDE_DIRECTORIES ${CODE_DIR}/botlib) + endforeach() +endfunction() + +function(add_asm TARGET) + if (MSVC) + enable_language(ASM_MASM) + set(ASM_SRCS) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + list(APPEND ASM_SRCS ../asm/vm_x86_64.asm) + endif() + list(APPEND ASM_SRCS ../asm/snapvector.asm ../asm/ftola.asm) + foreach(_file ${ASM_SRCS}) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set_property(SOURCE ${_file} APPEND PROPERTY COMPILE_DEFINITIONS idx64=1) + endif() + set_property(SOURCE ${_file} APPEND PROPERTY LANGUAGE ASM_MASM) + endforeach() + target_sources(${TARGET} PRIVATE ${ASM_SRCS}) + else() + target_sources(${TARGET} PRIVATE ../asm/snapvector.c ../asm/ftola.c) + endif() +endfunction() + +if (DEFAULT_BASEDIR) + add_compile_definitions(DEFAULT_BASEDIR="${DEFAULT_BASEDIR}") +endif() + +add_subdirectory(tools) + +set(RENDERER_LIST renderer_opengl1) +add_subdirectory(renderergl1) +if (BUILD_RENDERER_OPENGL2) + add_subdirectory(renderergl2) + list(APPEND RENDERER_LIST renderer_opengl2) +endif() + +add_subdirectory(cgame) +add_subdirectory(game) +add_subdirectory(q3_ui) + +if (BUILD_AUTOUPDATER) + add_subdirectory(autoupdater) +endif() +if (BUILD_CLIENT) + add_subdirectory(client) +endif() +if (BUILD_SERVER) + add_subdirectory(server) +endif() diff --git a/code/SDL2/CMakeLists.txt b/code/SDL2/CMakeLists.txt new file mode 100644 index 00000000000..8f06aab9e2d --- /dev/null +++ b/code/SDL2/CMakeLists.txt @@ -0,0 +1,34 @@ +if (MSVC) + set(SDL2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE STRING "") + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(SDL2_LIBRARIES ${LIBS_DIR}/libs/win64/SDL2.lib ${LIBS_DIR}/libs/win64/SDL2main.lib CACHE STRING "") + else() + set(SDL2_LIBRARIES ${LIBS_DIR}/libs/win32/SDL2.lib ${LIBS_DIR}/libs/win32/SDL2main.lib CACHE STRING "") + endif() +else() + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(SDL2 sdl2) + endif() + if (NOT SDL2_FOUND) + if (APPLE) + set(SDL2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE STRING "") + set(SDL2_LIBRARIES ${LIBS_DIR}/libs/macosx/libSDL2-2.0.0.dylib ${LIBS_DIR}/libs/macosx/libSDL2main.a CACHE STRING "") + elseif (MINGW) + set(SDL2_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include CACHE STRING "") + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(SDL2_LIBRARIES ${LIBS_DIR}/libs/win64/libSDL2.dll.a ${LIBS_DIR}/libs/win64/libSDL2main.a CACHE STRING "") + else() + set(SDL2_LIBRARIES ${LIBS_DIR}/libs/win32/libSDL2.dll.a ${LIBS_DIR}/libs/win32/libSDL2main.a CACHE STRING "") + endif() + endif() + endif() +endif() + +add_library(libSDL2 INTERFACE) +if (SDL2_LIBRARIES) + target_link_libraries(libSDL2 INTERFACE ${SDL2_LIBRARIES}) +endif() +if (SDL2_INCLUDE_DIRS) + target_include_directories(libSDL2 INTERFACE ${SDL2_INCLUDE_DIRS}) +endif() diff --git a/code/autoupdater/CMakeLists.txt b/code/autoupdater/CMakeLists.txt new file mode 100644 index 00000000000..912e517c6fc --- /dev/null +++ b/code/autoupdater/CMakeLists.txt @@ -0,0 +1,37 @@ +include(ExternalProject) + +project(autosyncerator) + +set(TFMVER 0.13.1) +set(LTCVER 1.17) + +find_program(MAKE_EXE NAMES gmake nmake make) + +ExternalProject_Add( + tomsfastmath + URL https://github.com/libtom/tomsfastmath/releases/download/v${TFMVER}/tfm-${TFMVER}.tar.xz + DOWNLOAD_NAME tfm-${TFMVER}.tar.xz + URL_HASH SHA256=47c97a1ada3ccc9fcbd2a8a922d5859a84b4ba53778c84c1d509c1a955ac1738 + STEP_TARGETS build + BUILD_COMMAND ${MAKE_EXE} +) + +ExternalProject_Get_Property(tomsfastmath source_dir) +set(TOMSFASTMATH_INCLUDE_DIRS ${source_dir}/src/headers) + +ExternalProject_Add( + tomscrypt + URL https://github.com/libtom/libtomcrypt/releases/download/$LTCVER/crypt-${LTCVER}.tar.bz2 + DOWNLOAD_NAME crypt-${LTCVER}.tar.bz2 + URL_HASH SHA256=e33b47d77a495091c8703175a25c8228aff043140b2554c08a3c3cd71f79d116 + DEPENDS tomsfastmath-build + BUILD_COMMAND ${MAKE_EXE} CFLAGS=-I${TOMSFASTMATH_INCLUDE_DIRS} +) + +ExternalProject_Get_Property(tomscrypt source_dir) +set(TOMSCRYPT_INCLUDE_DIRS ${source_dir}/src/headers) + +add_executable(${PROJECT_NAME} autoupdater.c) + +target_include_directories(${PROJECT_NAME} PRIVATE ${TOMSFASTMATH_INCLUDE_DIRS} ${TOMSFASTMATH_INCLUDE_DIRS}) +target_link_libraries(${PROJECT_NAME} curl) diff --git a/code/cgame/CMakeLists.txt b/code/cgame/CMakeLists.txt new file mode 100644 index 00000000000..993c8a2771b --- /dev/null +++ b/code/cgame/CMakeLists.txt @@ -0,0 +1,44 @@ +project(cgame) +set(SRCS + cg_consolecmds.c + cg_draw.c + cg_drawtools.c + cg_effects.c + cg_ents.c + cg_event.c + cg_info.c + cg_localents.c + cg_local.h + cg_main.c + cg_marks.c + cg_particles.c + cg_players.c + cg_playerstate.c + cg_predict.c + cg_public.h + cg_scoreboard.c + cg_servercmds.c + cg_snapshot.c + cg_view.c + cg_weapons.c + + ../game/bg_misc.c + ../game/bg_pmove.c + ../game/bg_slidemove.c + ../game/bg_lib.c + + ../qcommon/q_math.c + ../qcommon/q_shared.c +) +set(LIB_SRCS cg_syscalls.c) +set(QVM_SRCS ${SRCS} cg_syscalls.asm) +list(APPEND SRCS ${LIB_SRCS}) + +q3_add_library(TARGET cgame GAME_NAME baseq3 SRCS ${SRCS}) +target_compile_definitions(baseq3-cgame PRIVATE CGAME) +add_qvm(${PROJECT_NAME} baseq3 ${QVM_SRCS}) + +list(APPEND SRCS cg_newdraw.c) +q3_add_library(TARGET cgame GAME_NAME missionpack SRCS ${SRCS}) +target_compile_definitions(missionpack-cgame PRIVATE CGAME MISSIONPACK) +add_qvm(${PROJECT_NAME} missionpack ${QVM_SRCS}) diff --git a/code/client/CMakeLists.txt b/code/client/CMakeLists.txt new file mode 100644 index 00000000000..9e1471d6418 --- /dev/null +++ b/code/client/CMakeLists.txt @@ -0,0 +1,126 @@ +set(SRCS + cl_cgame.c + cl_cin.c + cl_console.c + cl_curl.c cl_curl.h + cl_input.c + cl_keys.c + cl_main.c + cl_net_chan.c + cl_parse.c + cl_scrn.c + cl_ui.c + cl_avi.c + client.h + keycodes.h + keys.h + qal.c qal.h + snd_altivec.c + snd_adpcm.c + snd_dma.c + snd_local.h + snd_mem.c + snd_mix.c + snd_wavelet.c + snd_main.c + snd_codec.c snd_codec.h + snd_codec_wav.c + snd_codec_ogg.c + snd_codec_opus.c + snd_public.h + snd_openal.c + ../qcommon/cm_load.c + ../qcommon/cm_patch.c + ../qcommon/cm_polylib.c + ../qcommon/cm_test.c + ../qcommon/cm_trace.c + ../qcommon/cmd.c + ../qcommon/common.c + ../qcommon/cvar.c + ../qcommon/files.c + ../qcommon/md4.c + ../qcommon/md5.c + ../qcommon/msg.c + ../qcommon/net_chan.c + ../qcommon/net_ip.c + ../qcommon/huffman.c + ../qcommon/q_math.c + ../qcommon/q_shared.c + ../qcommon/unzip.c + ../qcommon/ioapi.c + ../qcommon/puff.c + ../qcommon/vm.c + ../qcommon/vm_interpreted.c + ../qcommon/vm_x86.c + ../server/sv_bot.c + ../server/sv_ccmds.c + ../server/sv_client.c + ../server/sv_game.c + ../server/sv_init.c + ../server/sv_main.c + ../server/sv_net_chan.c + ../server/sv_snapshot.c + ../server/sv_world.c + ../sdl/sdl_input.c + ../sdl/sdl_snd.c + ../sys/con_log.c + ../sys/sys_loadlib.h + ../sys/sys_local.h + ../sys/sys_main.c + ../sys/sys_autoupdater.c +) + +if (WIN32) + list(APPEND SRCS ../sys/sys_win32.c) + list(APPEND SRCS ../sys/con_passive.c) + list(APPEND SRCS ../sys/win_resource.rc) +else() + if(APPLE) + list(APPEND SRCS ../sys/sys_osx.m) + endif() + list(APPEND SRCS ../sys/sys_unix.c) + list(APPEND SRCS ../sys/con_tty.c) +endif() + +if (USE_MUMBLE) + list(APPEND SRCS libmumblelink.c libmumblelink.h) +endif() + +project(${CLIENTBIN}) +q3_add_executable(TARGET ${PROJECT_NAME} WINDOWED SRCS ${SRCS}) +add_asm(${PROJECT_NAME}) +add_botlib(${PROJECT_NAME}) +add_dependencies(${PROJECT_NAME} baseq3-cgame baseq3-qagame baseq3-ui missionpack-cgame missionpack-qagame missionpack-ui ${RENDERER_LIST}) +set(CLIENT_DEFINES) +set(LIBS opusfile opus vorbis zlib openal libSDL2 ${CMAKE_DL_LIBS}) +if (MSVC) + list(APPEND LIBS ws2_32 winmm psapi gdi32 ole32) +elseif (APPLE) + set(FRAMEWORKS Cocoa Security IOKit) + foreach (_framework ${FRAMEWORKS}) + list(APPEND LIBS "-framework ${_framework}") + endforeach() + list(APPEND CLIENT_DEFINES _THREAD_SAFE=1) +else() + set(CMAKE_REQUIRED_LIBRARIES m) + check_symbol_exists("cosf" "math.h" HAVE_COSF) + set(CMAKE_REQUIRED_LIBRARIES) + list(APPEND LIBS m rt) +endif() +list(APPEND LIBS curl) +target_link_libraries(${PROJECT_NAME} ${LIBS}) +if (USE_VOIP) + list(APPEND CLIENT_DEFINES USE_VOIP) +endif() +if (USE_MUMBLE) + list(APPEND CLIENT_DEFINES USE_MUMBLE) +endif() +if (BUILD_AUTOUPDATER) + list(APPEND CLIENT_DEFINES USE_AUTOUPDATER) +endif() +if (USE_RENDERER_DLOPEN) + list(APPEND CLIENT_DEFINES USE_RENDERER_DLOPEN) +endif() +if (CLIENT_DEFINES) + target_compile_definitions(${PROJECT_NAME} PRIVATE ${CLIENT_DEFINES}) +endif() diff --git a/code/curl-7.54.0/CMakeLists.txt b/code/curl-7.54.0/CMakeLists.txt new file mode 100644 index 00000000000..90c935919bb --- /dev/null +++ b/code/curl-7.54.0/CMakeLists.txt @@ -0,0 +1,29 @@ +add_library(curl INTERFACE) + +find_package(CURL) +target_compile_definitions(curl INTERFACE USE_CURL) +if (CURL_FOUND) + set(LIBS ${CURL_LIBRARIES}) + set(INCLUDE_DIRS ${CURL_INCLUDE_DIRS}) +else() + set(INCLUDE_DIRS include) + if (MINGW) + if (CMAKE_SIZEOF_VOID_P EQUAL 8) + set(LIBS ${LIBS_DIR}/libs/win64/libcurl.a) + else() + set(LIBS ${LIBS_DIR}/libs/win32/libcurl.a) + endif() + target_compile_definitions(curl INTERFACE CURL_STATICLIB) + elseif (APPLE) + set(LIBS curl) + endif() +endif() + +if (NOT USE_CURL_DLOPEN OR MINGW) + if (LIBS) + target_link_libraries(curl INTERFACE ${LIBS}) + endif() +else() + target_compile_definitions(curl INTERFACE USE_CURL_DLOPEN) +endif() +target_include_directories(curl INTERFACE ${INCLUDE_DIRS}) diff --git a/code/game/CMakeLists.txt b/code/game/CMakeLists.txt new file mode 100644 index 00000000000..afb99a89116 --- /dev/null +++ b/code/game/CMakeLists.txt @@ -0,0 +1,57 @@ +project(game) +set(SRCS + ai_chat.c ai_chat.h + ai_cmd.c ai_cmd.h + ai_dmnet.c ai_dmnet.h + ai_dmq3.c ai_dmq3.h + ai_main.c ai_main.h + ai_team.c ai_team.h + ai_vcmd.c ai_vcmd.h + bg_lib.c bg_lib.h + bg_local.h + bg_misc.c + bg_pmove.c + bg_public.h + bg_slidemove.c + chars.h + g_active.c + g_arenas.c + g_bot.c + g_client.c + g_cmds.c + g_combat.c + g_items.c + g_local.h + g_main.c + g_mem.c + g_misc.c + g_missile.c + g_mover.c + g_public.h + #g_rankings.c g_rankings.h + g_session.c + g_spawn.c + g_svcmds.c + g_target.c + g_team.c + g_team.h + g_trigger.c + g_utils.c + g_weapon.c + inv.h + match.h + syn.h + + ../qcommon/q_math.c + ../qcommon/q_shared.c +) +set(LIB_SRCS g_syscalls.c) +set(QVM_SRCS ${SRCS} g_syscalls.asm) +list(APPEND SRCS ${LIB_SRCS}) +q3_add_library(TARGET qagame GAME_NAME baseq3 SRCS ${SRCS}) +target_compile_definitions(baseq3-qagame PRIVATE QAGAME) +add_qvm(qagame baseq3 ${QVM_SRCS}) + +q3_add_library(TARGET qagame GAME_NAME missionpack SRCS ${SRCS}) +target_compile_definitions(missionpack-qagame PRIVATE QAGAME MISSIONPACK) +add_qvm(qagame missionpack ${QVM_SRCS}) diff --git a/code/jpeg-8c/CMakeLists.txt b/code/jpeg-8c/CMakeLists.txt new file mode 100644 index 00000000000..f0f5bdf8d24 --- /dev/null +++ b/code/jpeg-8c/CMakeLists.txt @@ -0,0 +1,51 @@ +set(SRCS + jaricom.c + jcapimin.c + jcapistd.c + jcarith.c + jccoefct.c + jccolor.c + jcdctmgr.c + jchuff.c + jcinit.c + jcmainct.c + jcmarker.c + jcmaster.c + jcomapi.c + jcparam.c + jcprepct.c + jcsample.c + jctrans.c + jdapimin.c + jdapistd.c + jdarith.c + jdatadst.c + jdatasrc.c + jdcoefct.c + jdcolor.c + jddctmgr.c + jdhuff.c + jdinput.c + jdmainct.c + jdmarker.c + jdmaster.c + jdmerge.c + jdpostct.c + jdsample.c + jdtrans.c + jerror.c + jfdctflt.c + jfdctfst.c + jfdctint.c + jidctflt.c + jidctfst.c + jidctint.c + jmemmgr.c + jmemnobs.c + jquant1.c + jquant2.c + jutils.c +) +add_library(jpeg STATIC ${SRCS}) +target_include_directories(jpeg PUBLIC .) +target_compile_definitions(jpeg PUBLIC USE_INTERNAL_JPEG=1) diff --git a/code/libogg-1.3.3/CMakeLists.txt b/code/libogg-1.3.3/CMakeLists.txt new file mode 100644 index 00000000000..cf7c01e748e --- /dev/null +++ b/code/libogg-1.3.3/CMakeLists.txt @@ -0,0 +1,6 @@ +set(SRCS + src/bitwise.c + src/framing.c +) +add_library(ogg STATIC ${SRCS}) +target_include_directories(ogg PUBLIC include) diff --git a/code/libvorbis-1.3.6/CMakeLists.txt b/code/libvorbis-1.3.6/CMakeLists.txt new file mode 100644 index 00000000000..d501370eb79 --- /dev/null +++ b/code/libvorbis-1.3.6/CMakeLists.txt @@ -0,0 +1,28 @@ +set(SRCS + lib/lsp.c + lib/vorbisenc.c + lib/analysis.c + lib/floor0.c + lib/lpc.c + lib/codebook.c + lib/envelope.c + lib/mapping0.c + lib/vorbisfile.c + lib/bitrate.c + lib/sharedbook.c + lib/smallft.c + lib/info.c + lib/mdct.c + lib/lookup.c + lib/floor1.c + lib/block.c + lib/registry.c + lib/synthesis.c + lib/window.c + lib/psy.c + lib/res0.c +) +add_library(vorbis STATIC ${SRCS}) +target_link_libraries(vorbis PUBLIC ogg) +target_include_directories(vorbis PUBLIC include lib) +target_compile_definitions(vorbis PUBLIC USE_CODEC_VORBIS) diff --git a/code/opus-1.2.1/CMakeLists.txt b/code/opus-1.2.1/CMakeLists.txt new file mode 100644 index 00000000000..28395c8bc27 --- /dev/null +++ b/code/opus-1.2.1/CMakeLists.txt @@ -0,0 +1,149 @@ +set(SRCS + src/analysis.c + src/mlp.c + src/mlp_data.c + src/opus.c + src/opus_decoder.c + src/opus_encoder.c + src/opus_multistream.c + src/opus_multistream_encoder.c + src/opus_multistream_decoder.c + src/repacketizer.c + + celt/bands.c + celt/celt.c + celt/cwrs.c + celt/entcode.c + celt/entdec.c + celt/entenc.c + celt/kiss_fft.c + celt/laplace.c + celt/mathops.c + celt/mdct.c + celt/modes.c + celt/pitch.c + celt/celt_encoder.c + celt/celt_decoder.c + celt/celt_lpc.c + celt/quant_bands.c + celt/rate.c + celt/vq.c + + silk/CNG.c + silk/code_signs.c + silk/init_decoder.c + silk/decode_core.c + silk/decode_frame.c + silk/decode_parameters.c + silk/decode_indices.c + silk/decode_pulses.c + silk/decoder_set_fs.c + silk/dec_API.c + silk/enc_API.c + silk/encode_indices.c + silk/encode_pulses.c + silk/gain_quant.c + silk/interpolate.c + silk/LP_variable_cutoff.c + silk/NLSF_decode.c + silk/NSQ.c + silk/NSQ_del_dec.c + silk/PLC.c + silk/shell_coder.c + silk/tables_gain.c + silk/tables_LTP.c + silk/tables_NLSF_CB_NB_MB.c + silk/tables_NLSF_CB_WB.c + silk/tables_other.c + silk/tables_pitch_lag.c + silk/tables_pulses_per_block.c + silk/VAD.c + silk/control_audio_bandwidth.c + silk/quant_LTP_gains.c + silk/VQ_WMat_EC.c + silk/HP_variable_cutoff.c + silk/NLSF_encode.c + silk/NLSF_VQ.c + silk/NLSF_unpack.c + silk/NLSF_del_dec_quant.c + silk/process_NLSFs.c + silk/stereo_LR_to_MS.c + silk/stereo_MS_to_LR.c + silk/check_control_input.c + silk/control_SNR.c + silk/init_encoder.c + silk/control_codec.c + silk/A2NLSF.c + silk/ana_filt_bank_1.c + silk/biquad_alt.c + silk/bwexpander_32.c + silk/bwexpander.c + silk/debug.c + silk/decode_pitch.c + silk/inner_prod_aligned.c + silk/lin2log.c + silk/log2lin.c + silk/LPC_analysis_filter.c + silk/LPC_fit.c + silk/LPC_inv_pred_gain.c + silk/table_LSF_cos.c + silk/NLSF2A.c + silk/NLSF_stabilize.c + silk/NLSF_VQ_weights_laroia.c + silk/pitch_est_tables.c + silk/resampler.c + silk/resampler_down2_3.c + silk/resampler_down2.c + silk/resampler_private_AR2.c + silk/resampler_private_down_FIR.c + silk/resampler_private_IIR_FIR.c + silk/resampler_private_up2_HQ.c + silk/resampler_rom.c + silk/sigm_Q15.c + silk/sort.c + silk/sum_sqr_shift.c + silk/stereo_decode_pred.c + silk/stereo_encode_pred.c + silk/stereo_find_predictor.c + silk/stereo_quant_pred.c + + silk/float/apply_sine_window_FLP.c + silk/float/corrMatrix_FLP.c + silk/float/encode_frame_FLP.c + silk/float/find_LPC_FLP.c + silk/float/find_LTP_FLP.c + silk/float/find_pitch_lags_FLP.c + silk/float/find_pred_coefs_FLP.c + silk/float/LPC_analysis_filter_FLP.c + silk/float/LTP_analysis_filter_FLP.c + silk/float/LTP_scale_ctrl_FLP.c + silk/float/noise_shape_analysis_FLP.c + silk/float/process_gains_FLP.c + silk/float/regularize_correlations_FLP.c + silk/float/residual_energy_FLP.c + silk/float/warped_autocorrelation_FLP.c + silk/float/wrappers_FLP.c + silk/float/autocorrelation_FLP.c + silk/float/burg_modified_FLP.c + silk/float/bwexpander_FLP.c + silk/float/energy_FLP.c + silk/float/inner_product_FLP.c + silk/float/k2a_FLP.c + silk/float/LPC_inv_pred_gain_FLP.c + silk/float/pitch_analysis_core_FLP.c + silk/float/scale_copy_vector_FLP.c + silk/float/scale_vector_FLP.c + silk/float/schur_FLP.c + silk/float/sort_FLP.c +) +add_library(opus STATIC ${SRCS}) +target_include_directories(opus PUBLIC celt include silk silk/float) +target_compile_definitions(opus PRIVATE + FLOATING_POINT + FLOAT_APPROX + OPUS_BUILD + USE_ALLOCA + HAVE_LRINTF +) +target_compile_definitions(opus PUBLIC USE_CODEC_OPUS) +target_link_libraries(opus ogg) diff --git a/code/opusfile-0.9/CMakeLists.txt b/code/opusfile-0.9/CMakeLists.txt new file mode 100644 index 00000000000..0af8d63a901 --- /dev/null +++ b/code/opusfile-0.9/CMakeLists.txt @@ -0,0 +1,11 @@ +set(SRCS + src/http.c + src/info.c + src/internal.c + src/opusfile.c + src/stream.c + src/wincerts.c +) +add_library(opusfile STATIC ${SRCS}) +target_include_directories(opusfile PUBLIC include) +target_link_libraries(opusfile PRIVATE opus) diff --git a/code/q3_ui/CMakeLists.txt b/code/q3_ui/CMakeLists.txt new file mode 100644 index 00000000000..3ec4bf8fb74 --- /dev/null +++ b/code/q3_ui/CMakeLists.txt @@ -0,0 +1,65 @@ +project(ui) +set(SRCS + ui_addbots.c + ui_atoms.c + ui_cdkey.c + ui_cinematics.c + ui_confirm.c + ui_connect.c + ui_controls2.c + ui_credits.c + ui_demo2.c + ui_display.c + ui_gameinfo.c + ui_ingame.c + ui_loadconfig.c + ui_local.h + #ui_login.c + ui_main.c + ui_menu.c + ui_mfield.c + ui_mods.c + ui_network.c + ui_options.c + ui_playermodel.c + ui_players.c + ui_playersettings.c + ui_preferences.c + ui_qmenu.c + #ui_rankings.c + #ui_rankstatus.c + ui_removebots.c + ui_saveconfig.c + ui_serverinfo.c + ui_servers2.c + ui_setup.c + #ui_signup.c + ui_sound.c + ui_sparena.c + #ui_specifyleague.c + ui_specifyserver.c + ui_splevel.c + ui_sppostgame.c + ui_spreset.c + ui_spskill.c + ui_startserver.c + ui_team.c + ui_teamorders.c + ui_video.c + + ../game/bg_misc.c + ../game/bg_lib.c + ../qcommon/q_math.c + ../qcommon/q_shared.c +) +set(LIB_SRCS ../ui/ui_syscalls.c) +set(QVM_SRCS ${SRCS} ../ui/ui_syscalls.asm) +list(APPEND SRCS ${LIB_SRCS}) + +q3_add_library(TARGET ui GAME_NAME baseq3 SRCS ${SRCS}) +target_compile_definitions(baseq3-ui PRIVATE UI) +add_qvm(${PROJECT_NAME} baseq3 ${QVM_SRCS}) + +q3_add_library(TARGET ui GAME_NAME missionpack SRCS ${SRCS}) +target_compile_definitions(missionpack-ui PRIVATE UI MISSIONPACK) +add_qvm(${PROJECT_NAME} missionpack ${QVM_SRCS}) diff --git a/code/renderergl1/CMakeLists.txt b/code/renderergl1/CMakeLists.txt new file mode 100644 index 00000000000..cca7c3cd8b9 --- /dev/null +++ b/code/renderergl1/CMakeLists.txt @@ -0,0 +1,67 @@ +set(SRCS + tr_altivec.c + tr_animation.c + tr_backend.c + tr_bsp.c + tr_cmds.c + tr_curve.c + tr_flares.c + tr_image.c + tr_init.c + tr_light.c + tr_local.h + tr_main.c + tr_marks.c + tr_mesh.c + tr_model.c + tr_model_iqm.c + tr_scene.c + tr_shade.c + tr_shade_calc.c + tr_shader.c + tr_shadows.c + tr_sky.c + tr_surface.c + tr_world.c + ../renderercommon/iqm.h + ../renderercommon/qgl.h + ../renderercommon/tr_common.h + ../renderercommon/tr_font.c + ../renderercommon/tr_image_bmp.c + ../renderercommon/tr_image_jpg.c + ../renderercommon/tr_image_pcx.c + ../renderercommon/tr_image_png.c + ../renderercommon/tr_image_tga.c + ../renderercommon/tr_noise.c + ../renderercommon/tr_public.h + ../renderercommon/tr_types.h + ../sdl/sdl_gamma.c + ../sdl/sdl_glimp.c +) + +if (USE_RENDERER_DLOPEN) + list(APPEND SRCS + ../qcommon/q_shared.c + ../qcommon/puff.c + ../qcommon/q_math.c + tr_subs.c + ) +endif() + +project(renderer_opengl1) +q3_add_library(TARGET ${PROJECT_NAME} SRCS ${SRCS}) +set(LIBS jpeg libSDL2) +if (MSVC) + list(APPEND LIBS ws2_32 winmm psapi gdi32 ole32) +elseif (APPLE) + list(APPEND LIBS "-framework OpenGL") +endif() +target_link_libraries(${PROJECT_NAME} ${LIBS}) + +set(RENDERER_DEFINES) +if (USE_RENDERER_DLOPEN) + list(APPEND RENDERER_DEFINES USE_RENDERER_DLOPEN) +endif() +if (RENDERER_DEFINES) + target_compile_definitions(${PROJECT_NAME} PRIVATE ${RENDERER_DEFINES}) +endif() diff --git a/code/renderergl2/CMakeLists.txt b/code/renderergl2/CMakeLists.txt new file mode 100644 index 00000000000..9f25bc12885 --- /dev/null +++ b/code/renderergl2/CMakeLists.txt @@ -0,0 +1,120 @@ +set(SRCS + tr_animation.c + tr_backend.c + tr_bsp.c + tr_cmds.c + tr_curve.c + tr_dsa.c tr_dsa.h + tr_extramath.c tr_extramath.h + tr_extensions.c + tr_extratypes.h + tr_fbo.c tr_fbo.h + tr_flares.c + tr_glsl.c + tr_image.c + tr_image_dds.c + tr_init.c + tr_light.c + tr_local.h + tr_main.c + tr_marks.c + tr_mesh.c + tr_model.c + tr_model_iqm.c + tr_postprocess.c tr_postprocess.h + tr_scene.c + tr_shade.c + tr_shade_calc.c + tr_shader.c + tr_shadows.c + tr_sky.c + tr_surface.c + tr_vbo.c + tr_world.c + + ../renderercommon/iqm.h + ../renderercommon/qgl.h + ../renderercommon/tr_common.h + ../renderercommon/tr_font.c + ../renderercommon/tr_image_bmp.c + ../renderercommon/tr_image_jpg.c + ../renderercommon/tr_image_pcx.c + ../renderercommon/tr_image_png.c + ../renderercommon/tr_image_tga.c + ../renderercommon/tr_noise.c + ../renderercommon/tr_public.h + ../renderercommon/tr_types.h + + ../sdl/sdl_gamma.c + ../sdl/sdl_glimp.c +) + +set(SHADER_SRCS + glsl/bokeh_fp.glsl + glsl/bokeh_vp.glsl + glsl/calclevels4x_fp.glsl + glsl/calclevels4x_vp.glsl + glsl/depthblur_fp.glsl + glsl/depthblur_vp.glsl + glsl/dlight_fp.glsl + glsl/dlight_vp.glsl + glsl/down4x_fp.glsl + glsl/down4x_vp.glsl + glsl/fogpass_fp.glsl + glsl/fogpass_vp.glsl + glsl/generic_fp.glsl + glsl/generic_vp.glsl + glsl/lightall_fp.glsl + glsl/lightall_vp.glsl + glsl/pshadow_fp.glsl + glsl/pshadow_vp.glsl + glsl/shadowfill_fp.glsl + glsl/shadowfill_vp.glsl + glsl/shadowmask_fp.glsl + glsl/shadowmask_vp.glsl + glsl/ssao_fp.glsl + glsl/ssao_vp.glsl + glsl/texturecolor_fp.glsl + glsl/texturecolor_vp.glsl + glsl/tonemap_fp.glsl + glsl/tonemap_vp.glsl +) +list(APPEND SRCS ${SHADER_SRCS}) + +foreach (shader ${SHADER_SRCS}) + get_filename_component(shaderfile ${shader} NAME_WE) + list(APPEND SRCS ${CMAKE_CURRENT_BINARY_DIR}/${shaderfile}.c) + set_source_files_properties(${shaderfile}.c PROPERTIES GENERATED TRUE) + add_custom_command(OUTPUT ${shaderfile}.c + DEPENDS stringify ${CMAKE_CURRENT_SOURCE_DIR}/${shader} + COMMAND stringify ${CMAKE_CURRENT_SOURCE_DIR}/${shader} ${CMAKE_CURRENT_BINARY_DIR}/${shaderfile}.c + COMMENT "Generate c source for ${shader}: ${shaderfile}.c" + ) +endforeach() + +if (USE_RENDERER_DLOPEN) + list(APPEND SRCS + ../qcommon/q_shared.c + ../qcommon/puff.c + ../qcommon/q_math.c + tr_subs.c + ) +endif() + +project(renderer_opengl2) +q3_add_library(TARGET ${PROJECT_NAME} SRCS ${SRCS}) +set(LIBS jpeg libSDL2) +if (MSVC) + list(APPEND LIBS ws2_32 winmm psapi gdi32 ole32) +elseif (APPLE) + list(APPEND LIBS "-framework OpenGL") +endif() +target_link_libraries(${PROJECT_NAME} ${LIBS}) + +set(RENDERER_DEFINES) +if (USE_RENDERER_DLOPEN) + list(APPEND RENDERER_DEFINES -DUSE_RENDERER_DLOPEN) +endif() +if (RENDERER_DEFINES) + target_compile_definitions(${PROJECT_NAME} PRIVATE ${RENDERER_DEFINES}) +endif() diff --git a/code/server/CMakeLists.txt b/code/server/CMakeLists.txt new file mode 100644 index 00000000000..0062140f56f --- /dev/null +++ b/code/server/CMakeLists.txt @@ -0,0 +1,79 @@ +set(SRCS + server.h + sv_bot.c + sv_ccmds.c + sv_client.c + sv_game.c + sv_init.c + sv_main.c + sv_net_chan.c + sv_snapshot.c + sv_world.c + + ../null/null_client.c + ../null/null_input.c + ../null/null_snddma.c + ${QCOMMON_COLLISION_SRCS} + ../qcommon/cmd.c + ../qcommon/common.c + ../qcommon/cvar.c + ../qcommon/files.c + ../qcommon/huffman.c + ../qcommon/ioapi.c + ../qcommon/md4.c + ../qcommon/msg.c + ../qcommon/net_chan.c + ../qcommon/net_ip.c + ../qcommon/q_math.c + ../qcommon/q_shared.c + ../qcommon/unzip.c + ${QCOMMON_VM_SRCS} + ../sys/con_log.c + ../sys/sys_loadlib.h + ../sys/sys_local.h + ../sys/sys_main.c + ../sys/sys_autoupdater.c +) + +if (WIN32) + list(APPEND SRCS ../sys/sys_win32.c) + list(APPEND SRCS ../sys/con_win32.c) + list(APPEND SRCS ../sys/win_resource.rc) +else() + if(APPLE) + list(APPEND SRCS ../sys/sys_osx.m) + endif() + list(APPEND SRCS ../sys/sys_unix.c) + list(APPEND SRCS ../sys/con_tty.c) +endif() + +project(${SERVERBIN}) +q3_add_executable(TARGET ${PROJECT_NAME} SRCS ${SRCS}) +add_asm(${PROJECT_NAME}) +add_botlib(${PROJECT_NAME}) +add_dependencies(${PROJECT_NAME} baseq3-qagame missionpack-qagame) +set(SERVER_DEFINES -DDEDICATED) +set(LIBS zlib ${CMAKE_DL_LIBS}) +if (MSVC) + list(APPEND LIBS ws2_32 winmm psapi) +elseif (APPLE) + set(FRAMEWORKS Cocoa) + foreach (_framework ${FRAMEWORKS}) + list(APPEND LIBS "-framework ${_framework}") + endforeach() + list(APPEND SERVER_DEFINES -D_THREAD_SAFE=1) +else() + set(CMAKE_REQUIRED_LIBRARIES m) + check_symbol_exists("cosf" "math.h" HAVE_COSF) + set(CMAKE_REQUIRED_LIBRARIES) + list(APPEND LIBS m) +endif() +target_link_libraries(${PROJECT_NAME} ${LIBS}) +target_include_directories(${PROJECT_NAME} PRIVATE ../qcommon) +if (USE_VOIP) + list(APPEND SERVER_DEFINES USE_VOIP) +endif() +if (BUILD_AUTOUPDATER) + list(APPEND SERVER_DEFINES USE_AUTOUPDATER) +endif() +target_compile_definitions(${PROJECT_NAME} PRIVATE ${SERVER_DEFINES}) diff --git a/code/tools/CMakeLists.txt b/code/tools/CMakeLists.txt new file mode 100644 index 00000000000..d1a4dec163a --- /dev/null +++ b/code/tools/CMakeLists.txt @@ -0,0 +1,81 @@ + +if (MSVC) + # 4456 variable shadowing + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4456 /wd4311 /wd4312 /wd4255 /wd4389 /wd4459 /wd4996 /wd4018 /wd4210 /wd4457 /wd4706 /wd4710 /wd4774 /wd4711") +endif() + +add_executable(stringify stringify.c) + +set(Q3ASM_SRCS + asm/cmdlib.c + asm/q3asm.c +) +add_executable(q3asm ${Q3ASM_SRCS}) + +set(LBURG_SRCS + lcc/lburg/lburg.c + lcc/lburg/gram.c +) +add_executable(lburg ${LBURG_SRCS}) + +set(Q3CPP_SRCS + lcc/cpp/cpp.c + lcc/cpp/lex.c + lcc/cpp/nlist.c + lcc/cpp/tokens.c + lcc/cpp/macro.c + lcc/cpp/eval.c + lcc/cpp/include.c + lcc/cpp/hideset.c + lcc/cpp/getopt.c + lcc/cpp/unix.c +) +add_executable(q3cpp ${Q3CPP_SRCS}) + +set(Q3RCC_SRCS + dagcheck.c + + lcc/src/alloc.c + lcc/src/bind.c + lcc/src/bytecode.c + lcc/src/dag.c + lcc/src/decl.c + lcc/src/enode.c + lcc/src/error.c + lcc/src/event.c + lcc/src/expr.c + lcc/src/gen.c + lcc/src/init.c + lcc/src/inits.c + lcc/src/input.c + lcc/src/lex.c + lcc/src/list.c + lcc/src/main.c + lcc/src/null.c + lcc/src/output.c + lcc/src/prof.c + lcc/src/profio.c + lcc/src/simp.c + lcc/src/stmt.c + lcc/src/string.c + lcc/src/sym.c + lcc/src/symbolic.c + lcc/src/trace.c + lcc/src/tree.c + lcc/src/types.c +) +add_executable(q3rcc ${Q3RCC_SRCS}) +set_source_files_properties(dagcheck.c PROPERTIES GENERATED TRUE) +target_include_directories(q3rcc PRIVATE lcc/src) +add_custom_command(OUTPUT dagcheck.c + COMMAND lburg ${CMAKE_CURRENT_SOURCE_DIR}/lcc/src/dagcheck.md dagcheck.c + DEPENDS lburg + COMMENT "lburg dagcheck.c" +) + +set(Q3LCC_SRCS + lcc/etc/lcc.c + lcc/etc/bytecode.c +) +add_executable(q3lcc ${Q3LCC_SRCS}) +add_dependencies(q3lcc q3cpp q3rcc) diff --git a/code/zlib/CMakeLists.txt b/code/zlib/CMakeLists.txt new file mode 100644 index 00000000000..1a79dd05dfb --- /dev/null +++ b/code/zlib/CMakeLists.txt @@ -0,0 +1,11 @@ +set(SRCS + adler32.c + crc32.c + inffast.c + inflate.c + inftrees.c + zutil.c +) +add_library(zlib STATIC ${SRCS}) +target_include_directories(zlib PUBLIC .) +target_compile_definitions(zlib PRIVATE NO_GZIP) diff --git a/misc/osx/application.plist.in b/misc/osx/application.plist.in new file mode 100644 index 00000000000..939cc619a26 --- /dev/null +++ b/misc/osx/application.plist.in @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + en-US + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleIconFile + ${MACOSX_BUNDLE_ICON_FILE} + CFBundleName + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundlePackageType + APPL + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + NSHighResolutionCapable + + NSRequiresAquaSystemAppearance + + + diff --git a/misc/osx/copy_dylib.sh.in b/misc/osx/copy_dylib.sh.in new file mode 100644 index 00000000000..ca2ed54af87 --- /dev/null +++ b/misc/osx/copy_dylib.sh.in @@ -0,0 +1,74 @@ +#!/bin/bash + +#### Configuration: +# The name of the executable. It is assumed +# that it is in the current working directory. +EXE_NAME=@OUTPUTNAME@ +# Path to the executable directory inside the bundle. +# This must be an absolute path, so use $PWD. +EXEPATH=$PWD/@OUTPUTNAME@.app/Contents/MacOS +# Libraries to explicitly bundle, even though they +# may not be in /opt/local. One per line. These +# are used with grep, so only a portion of the name +# is required. eg: libFOX, libz, etc. +LIBS_TO_BUNDLE= + + +function copydeps { + local file=$1 + # echo "Copying deps for $file...." + local BASE_OF_EXE=`basename $file` + + # A will contain the dependencies of this library + local A=`otool -LX $file |cut -f 1 -d " "` + local i + for i in $A; do + local BASE=`basename $i` + + # See if it's a lib we specifically want to bundle + local bundle_this_lib=0 + local j + for j in $LIBS_TO_BUNDLE; do + echo $i |grep -q $j + if [ $? -eq 0 ]; then + bundle_this_lib=1 + echo "bundling $i because it's in the list." + break; + fi + done + + # See if it's in /opt/local. Bundle all in /opt/local + local isOptLocal=0 + echo $i |grep -q /opt + if [ $? -eq 0 ]; then + isOptLocal=1 + echo "bundling $i." + fi + + # Bundle the library + if [ $isOptLocal -ne 0 ] || [ $bundle_this_lib -ne 0 ]; then + # Copy the file into the bundle if it exists. + if [ -f $EXEPATH/$BASE ]; then + z=0 + else + cp $i $EXEPATH + chmod 755 $EXEPATH/$BASE + fi + + # Fix the paths using install_name_tool and then + # call this function recursively for each dependency + # of this library. + if [ $BASE_OF_EXE != $BASE ]; then + # Fix the paths + install_name_tool -id @executable_path/$BASE $EXEPATH/$BASE + install_name_tool -change $i @executable_path/$BASE $EXEPATH/$BASE_OF_EXE + + # Call this function (recursive) on + # on each dependency of this library. + copydeps $EXEPATH/$BASE + fi + fi + done +} + +copydeps $EXEPATH/$EXE_NAME