Support CMake on Microsoft Windows

This is a working CMake based build system for Windows:

- While this should work with system wide installed libraries, it's
  still highly recommended to use the latest version of our official
  Windows build environment.
- It was tested with out official build environment on Windows 7 with
  32 bit and 64 bit builds
- You'll need something in the lines of this nice and short command:
    cmake -G Unix\ Makefiles \
     -DSDL2_LIBRARY=C:/MinGW/32/LIBS/lib/libSDL2.dll.a \
     -DSDL2_INCLUDE_DIR=C:/MinGW/32/LIBS/include \
     -DZLIB_INCLUDE_DIR=C:/MinGW/32/LIBS/include \
     -DZLIB_LIBRARY=C:/MinGW/32/LIBS/lib/libz.a \
     -DOGG_LIBRARY=C:/MinGW/32/LIBS/lib/libogg.dll.a \
     -DOGG_INCLUDE_DIR=C:/MinGW/32/LIBS/include \
     -DVORBIS_LIBRARY=C:/MinGW/32/LIBS/lib/libvorbis.dll.a \
     -DVORBIS_INCLUDE_DIR=C:/MinGW/32/LIBS/include \
     -DVORBISFILE_LIBRARY=C:/MinGW/32/LIBS/lib/libvorbisfile.dll.a \
     -DVORBISENC_LIBRARY=C:/libvorbisenc.dll.a \
     -DOPENAL_LIBRARY=C:/MinGW/32/LIBS/lib/libOpenAL32.dll.a \
     -DOPENAL_INCLUDE_DIR=C:/MinGW/32/LIBS/include ..
 Yes, forward slashes! Backslashes will break!
This commit is contained in:
Yamagi Burmeister 2015-08-19 18:25:18 +02:00
parent 147021a89d
commit b89781d748
1 changed files with 18 additions and 3 deletions

View File

@ -97,7 +97,12 @@ if(${OPENAL_SUPPORT})
endif()
endif()
list(APPEND yquake2LinkerFlags "-lm -rdynamic")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
list(APPEND yquake2LinkerFlags "-lm")
else()
list(APPEND yquake2LinkerFlags "-lm -rdynamic")
endif()
list(APPEND yquake2LinkerFlags ${CMAKE_DL_LIBS})
# With all of those libraries and user defined paths
@ -137,6 +142,7 @@ set(Backends-Unix-Header
)
set(Backends-Windows-Source
${BACKENDS_SRC_DIR}/generic/misc.c
${BACKENDS_SRC_DIR}/windows/network.c
${BACKENDS_SRC_DIR}/windows/system.c
${BACKENDS_SRC_DIR}/windows/shared/mem.c
@ -401,7 +407,12 @@ set_target_properties(quake2 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Debug
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Release
)
target_link_libraries(quake2 game ${yquake2LinkerFlags})
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
target_link_libraries(quake2 game ${yquake2LinkerFlags} ws2_32 winmm)
else()
target_link_libraries(quake2 game ${yquake2LinkerFlags})
endif()
# Quake 2 Dedicated Server
add_executable(q2ded ${Server-Source} ${Server-Header} ${Platform-Specific-Source})
@ -411,5 +422,9 @@ set_target_properties(q2ded PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Debug
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Release
)
target_link_libraries(q2ded game ${yquake2LinkerFlags})
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
target_link_libraries(q2ded game ${yquake2LinkerFlags} ws2_32 winmm)
else()
target_link_libraries(q2ded game ${yquake2LinkerFlags})
endif()