add cmake-format.py and formating all cmake files
This commit is contained in:
parent
7bbd8bab34
commit
bb15d17892
3
.cmake-format.py
Normal file
3
.cmake-format.py
Normal file
@ -0,0 +1,3 @@
|
||||
tab_size = 4
|
||||
enable_sort = True
|
||||
autosort = True
|
||||
@ -9,9 +9,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
# We use two types linking: for clang build is static (vcpkg triplet x64-windows-static)
|
||||
# and for msvc build is dynamic linking (vcpkg triplet x64-windows)
|
||||
# By default CMAKE_MSVC_RUNTIME_LIBRARY set by MultiThreaded$<$<CONFIG:Debug>:Debug>DLL
|
||||
# We use two types linking: for clang build is static (vcpkg triplet
|
||||
# x64-windows-static) and for msvc build is dynamic linking (vcpkg triplet
|
||||
# x64-windows) By default CMAKE_MSVC_RUNTIME_LIBRARY set by
|
||||
# MultiThreaded$<$<CONFIG:Debug>:Debug>DLL
|
||||
if(VCPKG_TARGET_TRIPLET MATCHES "static")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
endif()
|
||||
@ -19,7 +20,8 @@ endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_executable(${PROJECT_NAME} src/main.cpp)
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
||||
if(VOXELENGINE_BUILD_APPDIR)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/BuildAppdir.cmake)
|
||||
@ -27,20 +29,31 @@ endif()
|
||||
|
||||
if(MSVC)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
set(CMAKE_BUILD_TYPE
|
||||
Release
|
||||
CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
if((CMAKE_BUILD_TYPE EQUAL "Release") OR (CMAKE_BUILD_TYPE EQUAL "RelWithDebInfo"))
|
||||
if((CMAKE_BUILD_TYPE EQUAL "Release") OR (CMAKE_BUILD_TYPE EQUAL
|
||||
"RelWithDebInfo"))
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /MT /O2)
|
||||
else()
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /source-charset:UTF-8 /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR")
|
||||
set(CMAKE_CXX_FLAGS
|
||||
"${CMAKE_CXX_FLAGS} /source-charset:UTF-8 /D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR"
|
||||
)
|
||||
else()
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra
|
||||
target_compile_options(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE -Wall
|
||||
-Wextra
|
||||
# additional warnings
|
||||
-Wformat-nonliteral -Wcast-align
|
||||
-Wpointer-arith -Wundef
|
||||
-Wwrite-strings -Wno-unused-parameter)
|
||||
-Wformat-nonliteral
|
||||
-Wcast-align
|
||||
-Wpointer-arith
|
||||
-Wundef
|
||||
-Wwrite-strings
|
||||
-Wno-unused-parameter)
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Og)
|
||||
endif()
|
||||
@ -63,10 +76,9 @@ target_link_libraries(${PROJECT_NAME} VoxelEngineSrc ${CMAKE_DL_LIBS})
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/res
|
||||
$<TARGET_FILE_DIR:${PROJECT_NAME}>/res
|
||||
)
|
||||
COMMAND
|
||||
${CMAKE_COMMAND} -E copy_directory_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/res $<TARGET_FILE_DIR:${PROJECT_NAME}>/res)
|
||||
|
||||
if(VOXELENGINE_BUILD_TESTS)
|
||||
enable_testing()
|
||||
|
||||
@ -27,10 +27,12 @@ endif()
|
||||
set(LIBS "")
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
# Use directly linking to lib instead PkgConfig (because pkg-config dont install on windows as default)
|
||||
# TODO: Do it with findLua.
|
||||
# Use directly linking to lib instead PkgConfig (because pkg-config dont
|
||||
# install on windows as default) TODO: Do it with findLua.
|
||||
if(MSVC)
|
||||
set(LUA_INCLUDE_DIR "$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit")
|
||||
set(LUA_INCLUDE_DIR
|
||||
"$ENV{VCPKG_ROOT}/packages/luajit_${VCPKG_TARGET_TRIPLET}/include/luajit"
|
||||
)
|
||||
find_package(Lua REQUIRED)
|
||||
else()
|
||||
# Used for mingw-clang cross compiling from msys2
|
||||
@ -70,4 +72,16 @@ endif()
|
||||
include_directories(${LUA_INCLUDE_DIR})
|
||||
include_directories(${CURL_INCLUDE_DIR})
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(${PROJECT_NAME} ${LIBS} glfw OpenGL::GL ${OPENAL_LIBRARY} GLEW::GLEW ZLIB::ZLIB PNG::PNG CURL::libcurl ${VORBISLIB} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS})
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
${LIBS}
|
||||
glfw
|
||||
OpenGL::GL
|
||||
${OPENAL_LIBRARY}
|
||||
GLEW::GLEW
|
||||
ZLIB::ZLIB
|
||||
PNG::PNG
|
||||
CURL::libcurl
|
||||
${VORBISLIB}
|
||||
${LUA_LIBRARIES}
|
||||
${CMAKE_DL_LIBS})
|
||||
|
||||
@ -8,23 +8,19 @@ find_package(GTest)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
VoxelEngineSrc
|
||||
GTest::gtest_main
|
||||
)
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src)
|
||||
target_link_libraries(${PROJECT_NAME} VoxelEngineSrc GTest::gtest_main)
|
||||
|
||||
# HACK: copy res to test/ folder for fixing problem compatibility MultiConfig and non
|
||||
# MultiConfig builds. Delete in future and use only root res folder
|
||||
# Also this resolve problem with ctests, because it set cwd to CMAKE_CURRENT_BINARY_DIR
|
||||
# HACK: copy res to test/ folder for fixing problem compatibility MultiConfig
|
||||
# and non MultiConfig builds. Delete in future and use only root res folder Also
|
||||
# this resolve problem with ctests, because it set cwd to
|
||||
# CMAKE_CURRENT_BINARY_DIR
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different
|
||||
${CMAKE_SOURCE_DIR}/res
|
||||
${CMAKE_CURRENT_BINARY_DIR}/res
|
||||
)
|
||||
${CMAKE_SOURCE_DIR}/res ${CMAKE_CURRENT_BINARY_DIR}/res)
|
||||
|
||||
include(GoogleTest)
|
||||
gtest_discover_tests(${PROJECT_NAME})
|
||||
|
||||
@ -8,24 +8,35 @@ add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
|
||||
if(MSVC)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
|
||||
set(CMAKE_BUILD_TYPE
|
||||
Release
|
||||
CACHE STRING "Build type" FORCE)
|
||||
endif()
|
||||
if((CMAKE_BUILD_TYPE EQUAL "Release") OR (CMAKE_BUILD_TYPE EQUAL "RelWithDebInfo"))
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Release>:Release>")
|
||||
if((CMAKE_BUILD_TYPE EQUAL "Release") OR (CMAKE_BUILD_TYPE EQUAL
|
||||
"RelWithDebInfo"))
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY
|
||||
"MultiThreaded$<$<CONFIG:Release>:Release>")
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /MT /O2)
|
||||
else()
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra
|
||||
-Wformat-nonliteral -Wcast-align
|
||||
-Wpointer-arith -Wundef
|
||||
-Wwrite-strings -Wno-unused-parameter)
|
||||
target_compile_options(
|
||||
${PROJECT_NAME}
|
||||
PRIVATE -Wall
|
||||
-Wextra
|
||||
-Wformat-nonliteral
|
||||
-Wcast-align
|
||||
-Wpointer-arith
|
||||
-Wundef
|
||||
-Wwrite-strings
|
||||
-Wno-unused-parameter)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie -lstdc++fs")
|
||||
endif()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_DL_LIBS})
|
||||
target_include_directories(
|
||||
${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_DL_LIBS})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user