Hi everyone,
we are using CMake to generate the build files for our project and make use of the findSFML module to use SFML.
Here's our CMakeLists file:
cmake_minimum_required(VERSION 3.0)
# forbid in-source build configurations
if("${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "Insource builds are forbidden, use another build directory")
endif()
project(Project-Onyx LANGUAGES CXX)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(ONYX_INSTALL_DIR "${CMAKE_BINARY_DIR}/install/${CMAKE_BUILD_TYPE}")
include(${CMAKE_MODULE_PATH}/cotire.cmake)
set(SFML_ROOT "" CACHE PATH "SFML root directory")
set(BOOST_ROOT "" CACHE PATH "Boost root directory")
find_package(Boost 1.58.0 EXACT REQUIRED)
find_package(SFML 2.3 COMPONENTS system window graphics audio EXACT REQUIRED)
include_directories(${SFML_INCLUDE_DIR} ${BOOST_INCLUDE_DIR})
file(GLOB_RECURSE SIMULATION_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/Simulation/*)
file(GLOB_RECURSE VISUALISATION_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src/Visualisation/*)
add_library(Simulation ${SIMULATION_SOURCE})
add_executable(Project-Onyx ${VISUALISATION_SOURCE})
target_link_libraries(Project-Onyx Simulation ${SFML_LIBRARIES})
set_property(TARGET Simulation Project-Onyx PROPERTY CXX_STANDARD 11)
install(TARGETS Project-Onyx DESTINATION "${ONYX_INSTALL_DIR}")
if(WIN32)
# get the SFML-DLLs
file(GLOB SFML_DEBUG_DLLS ${SFML_ROOT}/bin/*.dll)
install(FILES ${SFML_DEBUG_DLLS} DESTINATION "${ONYX_INSTALL_DIR}")
endif()
file(GLOB TEXTURE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/res/data)
install(DIRECTORY ${TEXTURE_DIR} DESTINATION "${ONYX_INSTALL_DIR}")
set_target_properties(Project-Onyx PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT ${CMAKE_CURRENT_SOURCE_DIR}/src/Visualisation/stdafx.h)
set_target_properties(Project-Onyx PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
set_target_properties(Simulation PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT ${CMAKE_CURRENT_SOURCE_DIR}/src/Simulation/stdafx.h)
set_target_properties(Simulation PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
cotire(Project-Onyx)
cotire(Simulation)
Generating the build files works fine. Building the project itself however (VS 2013) throws a Linker error:
LINK : fatal error LNK1104: cannot open file 'flac.lib' [C:\ProgramData\Jenkins\jobs\Project Onyx - Win - CMake - Release\workspace\build\Project-Onyx.vcxproj]
As far as I know, you don't have to link the SFML dependencies when linking SFML dynamically. Why do we still get this error?