Modding, Mission Design, and Coding > FS2 Open Coding - The Source Code Project (SCP)

The CMake build system

(1/13) > >>

m!m:
The new build system based on CMake has just been merged into master. This means that there are a few changes to how a build is compiled. A description of some common tasks can be found in the GitHub wiki: https://github.com/scp-fs2open/fs2open.github.com/wiki/CMake

Before you do anything, make sure you have updated your git submodules, either by running git submodule update --init --recursive or by cloning the repository with the --recursive flag.

Changes on Windows:
Previously we maintained multiple project files for the individual Visual Studio versions. These are no longer needed and have been removed. Instead, CMake now generates these files. First, you need to download the latest version of CMake from the website I linked above. Then, follow the steps in the Readme for generating your project files. The generated files are standard Visual Studio files so you can just open them using the standard methods.

Changes on Linux:
There aren't a lot of conceptual changes here. Instead of running ./autogen.sh you now need to run cmake.

Changes on Mac:
Similarly to Windows, you will now need to generate your project files. The process is similar to the Windows workflow so just follow those instructions.

If you have any troubles or questions about the new setup, I would be happy to answer them here or on IRC.

Yarn:
I get an error message whenever I try to generate the project files:

--- Quote ---Error in configuration process, project files may be invalid

--- End quote ---

Here's what gets logged to the bottom portion of the CMake window (errors are preceded by dashes):

--- Code: ---The C compiler identification is MSVC 19.0.24210.0
The CXX compiler identification is MSVC 19.0.24210.0
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
--CMake Error at cmake/toolchain-msvc.cmake:2 (include):
--  include could not find load file:
--
--    EnableExtraCompilerWarnings
--Call Stack (most recent call first):
--  cmake/toolchain.cmake:11 (include)
--  CMakeLists.txt:118 (INCLUDE)


Doing configuration specific to visual studio...
--CMake Error at cmake/toolchain-msvc.cmake:26 (globally_enable_extra_compiler_warnings):
--  Unknown CMake command "globally_enable_extra_compiler_warnings".
--Call Stack (most recent call first):
--  cmake/toolchain.cmake:11 (include)
--  CMakeLists.txt:118 (INCLUDE)


Configuring incomplete, errors occurred!
See also "C:/Games/FreeSpace2/fs2_open/master_build/CMakeFiles/CMakeOutput.log".

--- End code ---

In case it's useful, here's the CMakeCache.txt file that's generated:

--- Code: ---# This is the CMakeCache file.
# For build in directory: c:/Games/FreeSpace2/fs2_open/master_build
# It was generated by CMake: C:/Program Files/CMake/bin/cmake.exe
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.

########################
# EXTERNAL cache entries
########################

//Available configurations
CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release;FastDebug

//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING= /DWIN32 /D_WINDOWS /W3 /GR /EHsc

//Flags used by the compiler during debug builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1

//Flags used by the compiler during release builds for minimum
// size.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /DNDEBUG

//Flags used by the compiler during release builds.
CMAKE_CXX_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG

//Flags used by the compiler during release builds with debug info.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /DNDEBUG

//Libraries linked by default with all C++ applications.
CMAKE_CXX_STANDARD_LIBRARIES:STRING=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib

//Flags used by the compiler during all build types.
CMAKE_C_FLAGS:STRING= /DWIN32 /D_WINDOWS /W3

//Flags used by the compiler during debug builds.
CMAKE_C_FLAGS_DEBUG:STRING=/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1

//Flags used by the compiler during release builds for minimum
// size.
CMAKE_C_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /DNDEBUG

//Flags used by the compiler during release builds.
CMAKE_C_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG

//Flags used by the compiler during release builds with debug info.
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /DNDEBUG

//Libraries linked by default with all C applications.
CMAKE_C_STANDARD_LIBRARIES:STRING=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib

//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING= /machine:X86

//Flags used by the linker during debug builds.
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL

//Flags used by the linker during release minsize builds.
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO

//Flags used by the linker during release builds.
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO

//Flags used by the linker during Release with Debug Info builds.
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL

//Install path
CMAKE_INSTALL_PREFIX:FILEPATH=C:/Games/FreeSpace2

//Path to a program.
CMAKE_LINKER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/link.exe

//Flags used by the linker during the creation of modules.
CMAKE_MODULE_LINKER_FLAGS:STRING= /machine:X86

//Flags used by the linker during debug builds.
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL

//Flags used by the linker during release minsize builds.
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO

//Flags used by the linker during release builds.
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO

//Flags used by the linker during Release with Debug Info builds.
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL

//Value Computed by CMake
CMAKE_PROJECT_NAME:STATIC=FS2_Open

//RC compiler
CMAKE_RC_COMPILER:FILEPATH=rc

//Flags for Windows Resource Compiler.
CMAKE_RC_FLAGS:STRING=' /DWIN32 '

//Flags used by the linker during the creation of dll's.
CMAKE_SHARED_LINKER_FLAGS:STRING= /machine:X86

//Flags used by the linker during debug builds.
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL

//Flags used by the linker during release minsize builds.
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO

//Flags used by the linker during release builds.
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO

//Flags used by the linker during Release with Debug Info builds.
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL

//If set, runtime paths are not added when installing shared libraries,
// but are added when building.
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO

//If set, runtime paths are not added when using shared libraries.
CMAKE_SKIP_RPATH:BOOL=NO

//Flags used by the linker during the creation of static libraries.
CMAKE_STATIC_LINKER_FLAGS:STRING= /machine:X86

//Flags used by the linker during debug builds.
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=

//Flags used by the linker during release minsize builds.
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=

//Flags used by the linker during release builds.
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=

//Flags used by the linker during Release with Debug Info builds.
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=

//If this value is on, makefiles will be generated without the
// .SILENT directive, and all commands will be echoed to the console
// during the make.  This is useful for debugging only. With Visual
// Studio IDE projects all commands are done without /nologo.
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE

//Enable cotire, this speeds up builds but may cause issues while
// developing (default = OFF)
COTIRE_ENABLE:BOOL=OFF

//Executable output path
EXECUTABLE_OUTPUT_PATH:PATH=C:/Games/FreeSpace2/fs2_open/master_build/bin

//Value Computed by CMake
FS2_Open_BINARY_DIR:STATIC=C:/Games/FreeSpace2/fs2_open/master_build

//Value Computed by CMake
FS2_Open_SOURCE_DIR:STATIC=C:/Games/FreeSpace2/fs2_open/master

//Build FRED2 binary
FSO_BUILD_FRED2:BOOL=ON

//Build and use the included libraries istead of using the system
// headers and libraries
FSO_BUILD_INCLUDED_LIBS:BOOL=ON

//Build tools related to FSO
FSO_BUILD_TOOLS:BOOL=OFF

//Build wxFRED2 binary
FSO_BUILD_WXFRED2:BOOL=OFF

//Generate binaries in development mode, only use if you know what
// you're doing!
FSO_DEVELOPMENT_MODE:BOOL=OFF

//Determines if warnings in the build are considered fatal errors,
// primarily used for CI
FSO_FATAL_WARNINGS:BOOL=OFF

//The path of the FreeSpace directory you want to use. Please note
// that you will have to change CMAKE_INSTALL_PREFIX if you change
// this at some point.
FSO_FREESPACE_PATH:FILEPATH=C:/Games/FreeSpace2

//Install some debug files (currently only PDB files on windows)
FSO_INSTALL_DEBUG_FILES:BOOL=OFF

//Additional arguments passed to a generated executable when run
// with the generated build files.
FSO_RUN_ARGUMENTS:STRING=

//Use LuaJIT for Lua scripting, needs a working internet connection!
FSO_USE_LUAJIT:BOOL=OFF

//Download and build OpenAL Soft instead of using the system libraries
FSO_USE_OPENALSOFT:BOOL=OFF

//Use Windows specific text-to-speach libraries
FSO_USE_SPEECH:BOOL=ON

//Enable voice recognition support
FSO_USE_VOICEREC:BOOL=ON

//Library output path
LIBRARY_OUTPUT_PATH:PATH=C:/Games/FreeSpace2/fs2_open/master_build/bin

//Use the dynamically linked version of the runtime
MSVC_USE_RUNTIME_DLL:BOOL=OFF


########################
# INTERNAL cache entries
########################

//This is the directory where this CMakeCache.txt was created
CMAKE_CACHEFILE_DIR:INTERNAL=c:/Games/FreeSpace2/fs2_open/master_build
//Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
//Minor version of cmake used to create the current loaded cache
CMAKE_CACHE_MINOR_VERSION:INTERNAL=6
//Patch version of cmake used to create the current loaded cache
CMAKE_CACHE_PATCH_VERSION:INTERNAL=1
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cmake.exe
//Path to cpack program executable.
CMAKE_CPACK_COMMAND:INTERNAL=C:/Program Files/CMake/bin/cpack.exe
//Path to ctest program executable.
CMAKE_CTEST_COMMAND:INTERNAL=C:/Program Files/CMake/bin/ctest.exe
//ADVANCED property for variable: CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_STANDARD_LIBRARIES
CMAKE_CXX_STANDARD_LIBRARIES-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS
CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_STANDARD_LIBRARIES
CMAKE_C_STANDARD_LIBRARIES-ADVANCED:INTERNAL=1
//Executable file format
CMAKE_EXECUTABLE_FORMAT:INTERNAL=Unknown
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//Name of external makefile project generator.
CMAKE_EXTRA_GENERATOR:INTERNAL=
//Name of generator.
CMAKE_GENERATOR:INTERNAL=Visual Studio 14 2015
//Name of generator platform.
CMAKE_GENERATOR_PLATFORM:INTERNAL=
//Name of generator toolset.
CMAKE_GENERATOR_TOOLSET:INTERNAL=
//Source directory with the top level CMakeLists.txt file for this
// project
CMAKE_HOME_DIRECTORY:INTERNAL=C:/Games/FreeSpace2/fs2_open/master
//ADVANCED property for variable: CMAKE_LINKER
CMAKE_LINKER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//number of local generators
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_COMPILER
CMAKE_RC_COMPILER-ADVANCED:INTERNAL=1
CMAKE_RC_COMPILER_WORKS:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS
CMAKE_RC_FLAGS-ADVANCED:INTERNAL=1
//Path to CMake installation.
CMAKE_ROOT:INTERNAL=C:/Program Files/CMake/share/cmake-3.6
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SKIP_RPATH
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: COTIRE_ENABLE
COTIRE_ENABLE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: FSO_BUILD_INCLUDED_LIBS
FSO_BUILD_INCLUDED_LIBS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: FSO_DEVELOPMENT_MODE
FSO_DEVELOPMENT_MODE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: FSO_FATAL_WARNINGS
FSO_FATAL_WARNINGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: FSO_INSTALL_DEBUG_FILES
FSO_INSTALL_DEBUG_FILES-ADVANCED:INTERNAL=1
//ADVANCED property for variable: FSO_USE_LUAJIT
FSO_USE_LUAJIT-ADVANCED:INTERNAL=1
//ADVANCED property for variable: FSO_USE_OPENALSOFT
FSO_USE_OPENALSOFT-ADVANCED:INTERNAL=1
//ADVANCED property for variable: MSVC_USE_RUNTIME_DLL
MSVC_USE_RUNTIME_DLL-ADVANCED:INTERNAL=1
TARGET_COPY_DIRS:INTERNAL=
TARGET_COPY_FILES:INTERNAL=

--- End code ---

I'm using CMake 3.6.1 64-bit, Git for Windows 2.9.2 64-bit, and Visual Studio Community 2015 Update 3. This happens even with a clean repository checkout.

m!m:

--- Quote from: m!m on July 27, 2016, 08:36:29 am ---Before you do anything, make sure you have updated your git submodules, either by running git submodule update --init --recursive or by clong the repository with the --recursive flag.

--- End quote ---

Yarn:
I honestly thought that the "submodules" were part of Git for Windows and that those had to be updated by installing the latest Git for Windows. Guess I was totally wrong.

For those of us using TortoiseGit, you can update the submodules without using Bash by doing the following:

* Right-click the folder where you checked out the source code.
* Select "TortoiseGit", then "Submodule Update...".
* Make sure that all paths as well as the "Initialize submodules" and "Recursive" options are selected.
* Click OK.

The E:
To explain what submodules are in git parlance: A submodule is a way to link to an external git repository to pull in data from there. If you have a project that links to a specific library, you can use submodules to pull the code you need, eliminating the need to maintain a copy of that code by yourself.

Navigation

[0] Message Index

[#] Next page

Go to full version