Start using CMake targets instead of variables
Moved most of the variables to targets in the main src. Made libraries in repo export targets. Refactor STATIC flags a little and add more. This commit definitely breaks a lot of things like tests but the main game builds at least with MSVC.fix-squashed-planets
parent
f2d91cde80
commit
df65862c49
|
@ -144,9 +144,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
# Include cmake directory with some additional scripts
|
# Include cmake directory with some additional scripts
|
||||||
set(CMAKE_MODULE_PATH "${colobot_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH "${colobot_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||||
|
|
||||||
# MSVC needs different flags if linking statically
|
|
||||||
option(MSVC_STATIC "Link statically when using MSVC" OFF)
|
|
||||||
|
|
||||||
# Compiler detection
|
# Compiler detection
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
|
||||||
|
@ -187,12 +184,14 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
message(STATUS "Detected MSVC compiler")
|
message(STATUS "Detected MSVC compiler")
|
||||||
|
|
||||||
set(NORMAL_CXX_FLAGS "/wd\"4244\" /wd\"4309\" /wd\"4800\" /wd\"4996\" /wd\"4351\" /EHsc") # disable some useless warnings
|
set(NORMAL_CXX_FLAGS "/wd\"4244\" /wd\"4309\" /wd\"4800\" /wd\"4996\" /wd\"4351\" /EHsc") # disable some useless warnings
|
||||||
if(MSVC_STATIC)
|
if(BUILD_STATIC)
|
||||||
set(RELEASE_CXX_FLAGS "/MT /Ox")
|
set(RELEASE_CXX_FLAGS "/MT /Ox")
|
||||||
set(DEBUG_CXX_FLAGS "/MTd /ZI")
|
set(DEBUG_CXX_FLAGS "/MTd /ZI")
|
||||||
else(MSVC_STATIC)
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||||
|
else()
|
||||||
set(RELEASE_CXX_FLAGS "/MD /Ox")
|
set(RELEASE_CXX_FLAGS "/MD /Ox")
|
||||||
set(DEBUG_CXX_FLAGS "/MDd /ZI")
|
set(DEBUG_CXX_FLAGS "/MDd /ZI")
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL$<$<CONFIG:Debug>:Debug>")
|
||||||
endif()
|
endif()
|
||||||
set(TEST_CXX_FLAGS "")
|
set(TEST_CXX_FLAGS "")
|
||||||
add_definitions(-DNOEXCEPT= -DHAS_MSVC_EXCEPTION_BUG)
|
add_definitions(-DNOEXCEPT= -DHAS_MSVC_EXCEPTION_BUG)
|
||||||
|
@ -245,9 +244,6 @@ option(TESTS "Build tests" OFF)
|
||||||
# Building tool programs can be enabled/disabled
|
# Building tool programs can be enabled/disabled
|
||||||
option(TOOLS "Build tool programs" OFF)
|
option(TOOLS "Build tool programs" OFF)
|
||||||
|
|
||||||
# CBot can also be a static library
|
|
||||||
option(CBOT_STATIC "Build CBot as static libary" OFF)
|
|
||||||
|
|
||||||
# Generate desktop files, manpage, etc.
|
# Generate desktop files, manpage, etc.
|
||||||
option(DESKTOP "Generate desktop files, manpages, etc" ON)
|
option(DESKTOP "Generate desktop files, manpages, etc" ON)
|
||||||
|
|
||||||
|
@ -257,11 +253,20 @@ option(INSTALL_DOCS "Install Doxygen-generated documentation" OFF)
|
||||||
# Build OpenAL sound support
|
# Build OpenAL sound support
|
||||||
option(OPENAL_SOUND "Build OpenAL sound support" ON)
|
option(OPENAL_SOUND "Build OpenAL sound support" ON)
|
||||||
|
|
||||||
|
# Build Colobot with static libraries
|
||||||
|
option(BUILD_STATIC "The default linking option for external libraries" OFF)
|
||||||
|
|
||||||
|
# CBot can also be a static library
|
||||||
|
option(CBOT_STATIC "Build CBot as static libary" ${BUILD_STATIC})
|
||||||
|
|
||||||
# This is useful in case you want to use static boost libraries
|
# This is useful in case you want to use static boost libraries
|
||||||
option(BOOST_STATIC "Link with static boost libraries" OFF)
|
option(BOOST_STATIC "Link with static boost libraries" ${BUILD_STATIC})
|
||||||
|
|
||||||
# This is useful on Windows, if linking against standard GLEW dll fails
|
# This is useful on Windows, if linking against standard GLEW dll fails
|
||||||
option(GLEW_STATIC "Link statically with GLEW" OFF)
|
option(GLEW_STATIC "Link statically with GLEW" ${BUILD_STATIC})
|
||||||
|
|
||||||
|
# Link statically with LibSndFile
|
||||||
|
option(SNDFILE_STATIC "Link statically with LibSndFile" ${BUILD_STATIC})
|
||||||
|
|
||||||
# Sometimes helpful if there is a different version of gtest installed on system vs bundled
|
# Sometimes helpful if there is a different version of gtest installed on system vs bundled
|
||||||
option(FORCE_BUNDLED_GTEST "Force the use of bundled gtest" OFF)
|
option(FORCE_BUNDLED_GTEST "Force the use of bundled gtest" OFF)
|
||||||
|
@ -269,7 +274,6 @@ option(FORCE_BUNDLED_GTEST "Force the use of bundled gtest" OFF)
|
||||||
# This is for use with colobot-lint tool
|
# This is for use with colobot-lint tool
|
||||||
option(COLOBOT_LINT_BUILD "Generate some additional CMake targets for use with colobot-lint" OFF)
|
option(COLOBOT_LINT_BUILD "Generate some additional CMake targets for use with colobot-lint" OFF)
|
||||||
|
|
||||||
|
|
||||||
# Default build type if not given is debug
|
# Default build type if not given is debug
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
message(STATUS "Build type not specified - assuming debug")
|
message(STATUS "Build type not specified - assuming debug")
|
||||||
|
@ -301,12 +305,12 @@ set(Boost_USE_STATIC_RUNTIME OFF)
|
||||||
set(Boost_ADDITIONALVERSION "1.51" "1.51.0")
|
set(Boost_ADDITIONALVERSION "1.51" "1.51.0")
|
||||||
find_package(Boost COMPONENTS system filesystem regex REQUIRED)
|
find_package(Boost COMPONENTS system filesystem regex REQUIRED)
|
||||||
|
|
||||||
|
set(GLEW_USE_STATIC_LIBS ${GLEW_STATIC})
|
||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
|
|
||||||
if (OPENAL_SOUND)
|
if (OPENAL_SOUND)
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
include_directories(${OPENAL_INCLUDE_DIR})
|
find_package(SndFile REQUIRED)
|
||||||
find_package(LibSndFile REQUIRED)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
@ -345,10 +349,9 @@ include("${colobot_SOURCE_DIR}/cmake/colobot-lint.cmake")
|
||||||
# MSVC specific settings
|
# MSVC specific settings
|
||||||
##
|
##
|
||||||
set(WINGETOPT 0)
|
set(WINGETOPT 0)
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
if(MSVC)
|
||||||
message(STATUS "Adding MSVC-specific options")
|
message(STATUS "Adding MSVC-specific options")
|
||||||
|
|
||||||
set(CBOT_STATIC 1) # only this works for some reason
|
|
||||||
set(WINGETOPT 1) # use wingetopt library
|
set(WINGETOPT 1) # use wingetopt library
|
||||||
|
|
||||||
# Hide console in release builds
|
# Hide console in release builds
|
||||||
|
@ -360,7 +363,6 @@ endif()
|
||||||
##
|
##
|
||||||
# Localename
|
# Localename
|
||||||
##
|
##
|
||||||
set(LOCALENAME_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/localename)
|
|
||||||
add_subdirectory(lib/localename)
|
add_subdirectory(lib/localename)
|
||||||
|
|
||||||
|
|
||||||
|
@ -368,7 +370,6 @@ add_subdirectory(lib/localename)
|
||||||
# Wingetopt
|
# Wingetopt
|
||||||
##
|
##
|
||||||
if(WINGETOPT)
|
if(WINGETOPT)
|
||||||
set(WINGETOPT_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/wingetopt/src)
|
|
||||||
add_subdirectory(lib/wingetopt)
|
add_subdirectory(lib/wingetopt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -456,7 +457,7 @@ if(TESTS)
|
||||||
add_subdirectory(${GTEST_SRC_DIR} lib/gtest)
|
add_subdirectory(${GTEST_SRC_DIR} lib/gtest)
|
||||||
|
|
||||||
# Hippomocks library
|
# Hippomocks library
|
||||||
set(HIPPOMOCKS_INCLUDE_DIR ${colobot_SOURCE_DIR}/lib/hippomocks)
|
add_subdirectory(${colobot_SOURCE_DIR}/lib/hippomocks)
|
||||||
|
|
||||||
# Tests targets
|
# Tests targets
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.17)
|
cmake_minimum_required(VERSION 3.17)
|
||||||
|
|
||||||
include_directories(. include)
|
|
||||||
|
|
||||||
add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
|
|
||||||
|
|
||||||
# gtest-all.cc includes all other sources
|
# gtest-all.cc includes all other sources
|
||||||
add_library(gtest STATIC src/gtest-all.cc)
|
add_library(gtest STATIC src/gtest-all.cc)
|
||||||
|
target_include_directories(gtest PUBLIC . include)
|
||||||
|
target_compile_definitions(gtest PUBLIC GTEST_HAS_TR1_TUPLE=0)
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
cmake_minimum_required(VERSION 3.17)
|
||||||
|
|
||||||
|
add_library(hippomocks INTERFACE hippomocks.h)
|
||||||
|
target_include_directories(hippomocks INTERFACE ${CMAKE_CURRENT_LIST_DIR})
|
|
@ -1,3 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.17)
|
cmake_minimum_required(VERSION 3.17)
|
||||||
|
|
||||||
add_library(localename STATIC localename.c)
|
add_library(localename STATIC localename.c)
|
||||||
|
target_include_directories(localename PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.17)
|
cmake_minimum_required(VERSION 3.17)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|
||||||
add_library(wingetopt STATIC src/getopt.c src/getopt.h)
|
add_library(wingetopt STATIC src/getopt.c src/getopt.h)
|
||||||
|
target_include_directories(wingetopt PUBLIC ${CMAKE_CURRENT_LIST_DIR}/src)
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
set(SOURCES
|
if(CBOT_STATIC)
|
||||||
|
add_library(CBot STATIC)
|
||||||
|
else()
|
||||||
|
add_library(CBot SHARED)
|
||||||
|
install(TARGETS CBot
|
||||||
|
LIBRARY DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
|
||||||
|
ARCHIVE DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
|
||||||
|
RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_sources(CBot PRIVATE
|
||||||
CBot.h
|
CBot.h
|
||||||
CBotCStack.cpp
|
CBotCStack.cpp
|
||||||
CBotCStack.h
|
CBotCStack.h
|
||||||
|
@ -152,26 +162,5 @@ set(SOURCES
|
||||||
stdlib/stdlib.h
|
stdlib/stdlib.h
|
||||||
stdlib/stdlib_public.h
|
stdlib/stdlib_public.h
|
||||||
)
|
)
|
||||||
|
target_include_directories(CBot PUBLIC ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||||
# Includes
|
target_link_libraries(CBot PRIVATE Boost::headers)
|
||||||
set(LOCAL_INCLUDES
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SYSTEM_INCLUDES
|
|
||||||
${Boost_INCLUDE_DIRS}
|
|
||||||
)
|
|
||||||
|
|
||||||
include_directories(${LOCAL_INCLUDES})
|
|
||||||
include_directories(SYSTEM ${SYSTEM_INCLUDES})
|
|
||||||
|
|
||||||
|
|
||||||
if(CBOT_STATIC)
|
|
||||||
add_library(CBot STATIC ${SOURCES})
|
|
||||||
else()
|
|
||||||
add_library(CBot SHARED ${SOURCES})
|
|
||||||
install(TARGETS CBot LIBRARY
|
|
||||||
DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
|
|
||||||
ARCHIVE DESTINATION ${COLOBOT_INSTALL_LIB_DIR}
|
|
||||||
RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
# Compile flags as defined in global CMakeLists
|
# Compile flags as defined in global CMakeLists
|
||||||
|
# Todo: replace with target properties
|
||||||
set(CMAKE_CXX_FLAGS "${COLOBOT_CXX_FLAGS} ${MXE_CFLAGS}")
|
set(CMAKE_CXX_FLAGS "${COLOBOT_CXX_FLAGS} ${MXE_CFLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE ${COLOBOT_CXX_FLAGS_RELEASE})
|
set(CMAKE_CXX_FLAGS_RELEASE ${COLOBOT_CXX_FLAGS_RELEASE})
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG})
|
set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG})
|
||||||
|
|
||||||
# Subdirectories
|
# Subdirectories
|
||||||
|
|
||||||
add_subdirectory(CBot)
|
add_subdirectory(CBot)
|
||||||
|
|
||||||
if(TOOLS)
|
if(TOOLS)
|
||||||
|
@ -13,122 +13,12 @@ endif()
|
||||||
|
|
||||||
add_subdirectory(graphics/opengl/shaders)
|
add_subdirectory(graphics/opengl/shaders)
|
||||||
|
|
||||||
|
|
||||||
# Optional libraries
|
|
||||||
set(OPTIONAL_LIBS "")
|
|
||||||
set(OPTIONAL_INCLUDES "")
|
|
||||||
|
|
||||||
if(OPENAL_SOUND)
|
|
||||||
set(OPTIONAL_LIBS ${OPENAL_LIBRARY})
|
|
||||||
set(OPTIONAL_INCLUDES ${OPENAL_INCLUDE_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WINGETOPT)
|
|
||||||
set(OPTIONAL_LIBS ${OPTIONAL_LIBS} wingetopt)
|
|
||||||
set(OPTIONAL_INCLUDES ${OPTIONAL_INCLUDES} ${WINGETOPT_INCLUDE_DIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Additional libraries per platform
|
|
||||||
if(MXE) # MXE requires special treatment
|
|
||||||
set(PLATFORM_LIBS ${MXE_LIBS})
|
|
||||||
elseif(PLATFORM_WINDOWS)
|
|
||||||
# because it isn't included in standard linking libraries
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|
||||||
find_library(LIBINTL_LIBRARY NAMES intl.lib libintl)
|
|
||||||
|
|
||||||
if(${MSVC_STATIC})
|
|
||||||
if (${OPENAL_SOUND})
|
|
||||||
find_library(FLAC_LIBRARY NAMES flac.lib)
|
|
||||||
find_library(VORBIS_LIBRARY NAMES vorbis.lib)
|
|
||||||
find_library(VORBISENC_LIBRARY NAMES vorbisenc.lib)
|
|
||||||
find_library(OGG_LIBRARY NAMES ogg.lib)
|
|
||||||
set(OPENAL_MSVC_LIBS
|
|
||||||
${FLAC_LIBRARY}
|
|
||||||
${VORBIS_LIBRARY}
|
|
||||||
${VORBISENC_LIBRARY}
|
|
||||||
${OGG_LIBRARY}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(BZ2_LIBRARY NAMES bz2.lib)
|
|
||||||
find_library(JPEG_LIBRARY NAMES jpeg.lib)
|
|
||||||
find_library(TIFF_LIBRARY NAMES tiff.lib)
|
|
||||||
find_library(LZMA_LIBRARY NAMES lzma.lib)
|
|
||||||
find_library(FREETYPE_LIBRARY NAMES freetype.lib)
|
|
||||||
find_library(ICONV_LIBRARY NAMES libiconv.lib)
|
|
||||||
find_library(CHARSET_LIBRARY NAMES libcharset.lib)
|
|
||||||
set(MSVC_LIBS
|
|
||||||
${LIBINTL_LIBRARY}
|
|
||||||
${OPENAL_MSVC_LIBS}
|
|
||||||
${JPEG_LIBRARY}
|
|
||||||
${TIFF_LIBRARY}
|
|
||||||
${BZ2_LIBRARY}
|
|
||||||
${LZMA_LIBRARY}
|
|
||||||
${FREETYPE_LIBRARY}
|
|
||||||
${ICONV_LIBRARY}
|
|
||||||
${CHARSET_LIBRARY}
|
|
||||||
winmm.lib
|
|
||||||
dxguid.lib
|
|
||||||
imm32.lib
|
|
||||||
ole32.lib
|
|
||||||
oleaut32.lib
|
|
||||||
version.lib
|
|
||||||
wsock32.lib
|
|
||||||
ws2_32.lib
|
|
||||||
setupapi.lib
|
|
||||||
)
|
|
||||||
else(${MSVC_STATIC})
|
|
||||||
set(MSVC_LIBS ${LIBINTL_LIBRARY})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(PLATFORM_LIBS ${MSVC_LIBS})
|
|
||||||
else()
|
|
||||||
set(PLATFORM_LIBS "-lintl")
|
|
||||||
endif()
|
|
||||||
elseif(PLATFORM_GNU)
|
|
||||||
set(PLATFORM_LIBS "")
|
|
||||||
elseif(PLATFORM_LINUX)
|
|
||||||
# for clock_gettime
|
|
||||||
set(PLATFORM_LIBS "-lrt")
|
|
||||||
elseif(PLATFORM_MACOSX)
|
|
||||||
find_library(LIBINTL_LIBRARY NAMES intl libintl)
|
|
||||||
find_path(LIBINTL_INCLUDE_PATH NAMES libintl.h)
|
|
||||||
set(PLATFORM_LIBS ${LIBINTL_LIBRARY})
|
|
||||||
elseif(PLATFORM_FREEBSD)
|
|
||||||
find_library(LIBINTL_LIBRARY NAMES intl libintl)
|
|
||||||
find_path(LIBINTL_INCLUDE_PATH NAMES libintl.h)
|
|
||||||
set(PLATFORM_LIBS ${LIBINTL_LIBRARY})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
# Configure file
|
# Configure file
|
||||||
configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
|
configure_file(common/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/config.h)
|
||||||
configure_file(common/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/version.h)
|
configure_file(common/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/common/version.h)
|
||||||
|
|
||||||
set(OPENAL_SRC "")
|
# Todo: split this monstrosity into smaller libraries (graphics, math, ui, etc.)
|
||||||
|
add_library(colobotbase STATIC
|
||||||
if(OPENAL_SOUND)
|
|
||||||
set(OPENAL_SRC
|
|
||||||
sound/oalsound/alsound.cpp
|
|
||||||
sound/oalsound/buffer.cpp
|
|
||||||
sound/oalsound/channel.cpp
|
|
||||||
sound/oalsound/check.cpp
|
|
||||||
sound/oalsound/alsound.h
|
|
||||||
sound/oalsound/buffer.h
|
|
||||||
sound/oalsound/channel.h
|
|
||||||
sound/oalsound/check.h
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(RES_FILES "")
|
|
||||||
|
|
||||||
if(PLATFORM_WINDOWS)
|
|
||||||
set(RES_FILES "../desktop/colobot.rc")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Source files
|
|
||||||
set(BASE_SOURCES
|
|
||||||
${OPENAL_SRC}
|
|
||||||
app/app.cpp
|
app/app.cpp
|
||||||
app/app.h
|
app/app.h
|
||||||
app/controller.cpp
|
app/controller.cpp
|
||||||
|
@ -579,77 +469,121 @@ set(BASE_SOURCES
|
||||||
ui/studio.h
|
ui/studio.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(MAIN_SOURCES
|
target_include_directories(colobotbase PUBLIC
|
||||||
app/main.cpp
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
${RES_FILES}
|
${CMAKE_CURRENT_LIST_DIR}/..
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Libraries
|
# Main libraries
|
||||||
set(LIBS
|
target_link_libraries(colobotbase PUBLIC
|
||||||
CBot
|
CBot
|
||||||
localename
|
localename
|
||||||
${SDL2_LIBRARY}
|
SDL2::Core
|
||||||
${SDL2_IMAGE_LIBRARY}
|
SDL2::Image
|
||||||
${SDL2_TTF_LIBRARY}
|
SDL2::TTF
|
||||||
${OPENGL_LIBRARY}
|
OpenGL::GL
|
||||||
${PNG_LIBRARIES}
|
PNG::PNG
|
||||||
${GLEW_LIBRARY}
|
GLEW::GLEW
|
||||||
${Boost_LIBRARIES}
|
Boost::headers
|
||||||
${LIBSNDFILE_LIBRARY}
|
Boost::filesystem
|
||||||
${OPTIONAL_LIBS}
|
Boost::regex
|
||||||
${PLATFORM_LIBS}
|
PhysFS::PhysFS
|
||||||
${PHYSFS_LIBRARY}
|
SndFile::sndfile
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Optional libraries
|
||||||
|
if(OPENAL_SOUND)
|
||||||
|
target_sources(colobotbase PRIVATE
|
||||||
|
sound/oalsound/alsound.cpp
|
||||||
|
sound/oalsound/buffer.cpp
|
||||||
|
sound/oalsound/channel.cpp
|
||||||
|
sound/oalsound/check.cpp
|
||||||
|
sound/oalsound/alsound.h
|
||||||
|
sound/oalsound/buffer.h
|
||||||
|
sound/oalsound/channel.h
|
||||||
|
sound/oalsound/check.h
|
||||||
|
)
|
||||||
|
target_link_libraries(colobotbase PUBLIC OpenAL::OpenAL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WINGETOPT)
|
||||||
|
target_link_libraries(colobotbase PUBLIC wingetopt)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Additional libraries per platform
|
||||||
|
if(MXE) # MXE requires special treatment
|
||||||
|
target_link_libraries(colobotbase PUBLIC ${MXE_LIBS})
|
||||||
|
elseif(PLATFORM_WINDOWS)
|
||||||
|
# because it isn't included in standard linking libraries
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
|
if(BUILD_STATIC)
|
||||||
|
find_package(Intl REQUIRED)
|
||||||
|
#todo figure out why those dependencies are needed and find them in a better way
|
||||||
|
find_library(BZ2_LIBRARY NAMES bz2.lib)
|
||||||
|
find_library(JPEG_LIBRARY NAMES jpeg.lib)
|
||||||
|
find_library(TIFF_LIBRARY NAMES tiff.lib)
|
||||||
|
find_library(LZMA_LIBRARY NAMES lzma.lib)
|
||||||
|
find_library(FREETYPE_LIBRARY NAMES freetype.lib)
|
||||||
|
find_library(ICONV_LIBRARY NAMES libiconv.lib)
|
||||||
|
find_library(CHARSET_LIBRARY NAMES libcharset.lib)
|
||||||
|
|
||||||
|
target_link_libraries(colobotbase PUBLIC
|
||||||
|
Gettext::Intl
|
||||||
|
${JPEG_LIBRARY}
|
||||||
|
${TIFF_LIBRARY}
|
||||||
|
${BZ2_LIBRARY}
|
||||||
|
${LZMA_LIBRARY}
|
||||||
|
${FREETYPE_LIBRARY}
|
||||||
|
${ICONV_LIBRARY}
|
||||||
|
${CHARSET_LIBRARY}
|
||||||
|
|
||||||
|
# why
|
||||||
|
winmm.lib
|
||||||
|
dxguid.lib
|
||||||
|
imm32.lib
|
||||||
|
ole32.lib
|
||||||
|
oleaut32.lib
|
||||||
|
version.lib
|
||||||
|
wsock32.lib
|
||||||
|
ws2_32.lib
|
||||||
|
setupapi.lib
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
target_link_libraries(colobotbase PUBLIC -lintl)
|
||||||
|
endif()
|
||||||
|
elseif(PLATFORM_GNU)
|
||||||
|
# nothing
|
||||||
|
elseif(PLATFORM_LINUX)
|
||||||
|
# for clock_gettime
|
||||||
|
target_link_libraries(colobotbase PUBLIC -lrt)
|
||||||
|
elseif(PLATFORM_MACOSX)
|
||||||
|
find_package(Intl REQUIRED)
|
||||||
|
target_link_libraries(colobotbase PUBLIC Gettext::Intl)
|
||||||
|
elseif(PLATFORM_FREEBSD)
|
||||||
|
find_package(Intl REQUIRED)
|
||||||
|
target_link_libraries(colobotbase PUBLIC Gettext::Intl)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
set(COLOBOT_LIBS ${LIBS} PARENT_SCOPE)
|
set(COLOBOT_LIBS ${LIBS} PARENT_SCOPE)
|
||||||
|
|
||||||
|
|
||||||
# Includes
|
|
||||||
set(LOCAL_INCLUDES
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SYSTEM_INCLUDES
|
|
||||||
${SDL2_INCLUDE_DIR}
|
|
||||||
${SDL2_IMAGE_INCLUDE_DIR}
|
|
||||||
${SDL2_TTF_INCLUDE_DIR}
|
|
||||||
${PNG_INCLUDE_DIRS}
|
|
||||||
${GLEW_INCLUDE_PATH}
|
|
||||||
${Boost_INCLUDE_DIRS}
|
|
||||||
${LIBSNDFILE_INCLUDE_DIR}
|
|
||||||
${LOCALENAME_INCLUDE_DIR}
|
|
||||||
${PHYSFS_INCLUDE_PATH}
|
|
||||||
${LIBINTL_INCLUDE_PATH}
|
|
||||||
${OPTIONAL_INCLUDES}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(COLOBOT_LOCAL_INCLUDES ${LOCAL_INCLUDES} PARENT_SCOPE)
|
|
||||||
set(COLOBOT_SYSTEM_INCLUDES ${SYSTEM_INCLUDES} PARENT_SCOPE)
|
|
||||||
|
|
||||||
include_directories(${LOCAL_INCLUDES})
|
|
||||||
include_directories(SYSTEM ${SYSTEM_INCLUDES})
|
|
||||||
|
|
||||||
|
|
||||||
# Link directories
|
|
||||||
link_directories(
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CBot
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Targets
|
# Targets
|
||||||
|
add_executable(colobot app/main.cpp)
|
||||||
|
if(PLATFORM_WINDOWS)
|
||||||
|
target_sources(colobot PRIVATE ../desktop/colobot.rc)
|
||||||
|
endif()
|
||||||
|
target_link_libraries(colobot colobotbase SDL2::Main)
|
||||||
|
|
||||||
add_library(colobotbase STATIC ${BASE_SOURCES})
|
# Install
|
||||||
|
|
||||||
add_executable(colobot ${MAIN_SOURCES})
|
|
||||||
target_link_libraries(colobot colobotbase ${LIBS})
|
|
||||||
|
|
||||||
install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
|
install(TARGETS colobot RUNTIME DESTINATION ${COLOBOT_INSTALL_BIN_DIR})
|
||||||
if(NOT CBOT_STATIC)
|
if(NOT CBOT_STATIC)
|
||||||
set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
|
set_target_properties(colobot PROPERTIES INSTALL_RPATH ${COLOBOT_INSTALL_LIB_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Linter-specific
|
||||||
if(COLOBOT_LINT_BUILD)
|
if(COLOBOT_LINT_BUILD)
|
||||||
add_fake_header_sources("src")
|
add_fake_header_sources("src")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,15 +1,9 @@
|
||||||
set(CONVERT_MODEL_SOURCES
|
add_executable(convert_model
|
||||||
../common/logger.cpp
|
../common/logger.cpp
|
||||||
../graphics/model/model.cpp
|
../graphics/model/model.cpp
|
||||||
../graphics/model/model_mesh.cpp
|
../graphics/model/model_mesh.cpp
|
||||||
../graphics/model/model_input.cpp
|
../graphics/model/model_input.cpp
|
||||||
../graphics/model/model_output.cpp
|
../graphics/model/model_output.cpp
|
||||||
convert_model.cpp
|
convert_model.cpp)
|
||||||
)
|
target_include_directories(convert_model PRIVATE . ..) #todo SDL2
|
||||||
|
|
||||||
include_directories(. ..)
|
|
||||||
|
|
||||||
include_directories(SYSTEM ${SDL_INCLUDE_DIR})
|
|
||||||
|
|
||||||
add_executable(convert_model ${CONVERT_MODEL_SOURCES})
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue