1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-06 09:09:40 +02:00

CMake: cleanup, project generation and other improvements

- Use EXCLUDE_FROM_ALL for FuzzyLite and GoogleTest to avoid inclusion of unneded headers and libraries into installers.
- Set minimum CMake version only in main CMakeLists.txt
- Set project name only in main CMakeLists.txt
- Visual Studio: add assign_source_group function to generate proper filesystem tree
- Visual Studio: set PROJECT_LABEL so generated projects have same names binaries on Windows
- Visual Studio: enabled USE_FOLDERS for projects grouping. This also possibly affect other IDEs.
- Added add_subdirectory_with_folder function to make sure 3rd-party libraries are affected by USE_FOLDERS.
This commit is contained in:
Arseniy Shestakov
2017-08-15 21:17:00 +03:00
parent b3b29cfda9
commit 193f492b99
14 changed files with 256 additions and 257 deletions

View File

@@ -1,16 +1,12 @@
cmake_minimum_required(VERSION 2.8.7)
project(test)
enable_testing()
set(googleTest_Dir ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
if (EXISTS ${googleTest_Dir})
if(EXISTS ${googleTest_Dir})
SET(GTestSrc ${googleTest_Dir}/googletest)
SET(GMockSrc ${googleTest_Dir}/googlemock)
else ()
message( FATAL_ERROR "No googletest src dir found!")
endif ()
else()
message(FATAL_ERROR "No googletest src dir found!")
endif()
include_directories(${GTestSrc} ${GTestSrc}/include ${GMockSrc} ${GMockSrc}/include)
include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/test)
include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
@@ -36,10 +32,13 @@ set(test_HEADERS
map/MapComparer.h
)
assign_source_group(${test_SRCS} ${test_HEADERS})
set(mock_HEADERS
mock/mock_UnitHealthInfo.h
)
add_subdirectory(googletest)
add_subdirectory(googletest EXCLUDE_FROM_ALL)
add_executable(vcmitest ${test_SRCS} ${test_HEADERS} ${mock_HEADERS} ${GTestSrc}/src/gtest-all.cc ${GMockSrc}/src/gmock-all.cc)
target_link_libraries(vcmitest vcmi ${RT_LIB} ${DL_LIB})
@@ -62,7 +61,7 @@ set(vcmitest_FILES
)
foreach(file ${vcmitest_FILES})
add_custom_command(TARGET vcmitestFiles POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${file}" ${CMAKE_CURRENT_BINARY_DIR}
add_custom_command(TARGET vcmitestFiles POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${file}" ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()