54 lines
1.6 KiB
CMake
54 lines
1.6 KiB
CMake
cmake_minimum_required(VERSION 3.13)
|
|
|
|
# Make warnings trigger errors.
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
|
|
|
project(pkmnLib)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
if (WINDOWS)
|
|
ADD_DEFINITIONS(-D WINDOWS=1)
|
|
endif(WINDOWS)
|
|
|
|
if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
conan_basic_setup()
|
|
else ()
|
|
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
|
|
endif ()
|
|
|
|
message(STATUS "Using ${CMAKE_CXX_COMPILER}")
|
|
|
|
# Create Core library with files in src/Core
|
|
file(GLOB_RECURSE CORE_SRC_FILES "src/*.cpp" "src/*.hpp")
|
|
add_library(pkmnLib SHARED ${CORE_SRC_FILES})
|
|
|
|
if (NOT DEFINED CONAN_EXPORTED)
|
|
# Create Test executable
|
|
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
|
add_executable(pkmnLibTests ${TEST_FILES} extern/catch.hpp)
|
|
endif ()
|
|
|
|
|
|
foreach (_variableName ${CONAN_LIBS})
|
|
message(STATUS "Lib: ${_variableName}")
|
|
endforeach()
|
|
|
|
#target_link_libraries(pkmnLib ${CONAN_LIBS})
|
|
conan_target_link_libraries(pkmnLib)
|
|
target_link_libraries(pkmnLibTests pkmnLib)
|
|
|
|
if (WINDOWS)
|
|
message(STATUS "Using Windows build.")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition")
|
|
# Statically link libraries we need in Windows.
|
|
target_link_libraries(pkmnLib -static -static-libgcc -static-libstdc++)
|
|
target_link_libraries(pkmnLibTests -static -static-libgcc -static-libstdc++)
|
|
endif (WINDOWS)
|
|
|
|
# Add a definition for the test library
|
|
target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)
|
|
|