mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
Merge pull request #435 from Ygrik2003/Refactoring-cmake
Refactoring cmake
This commit is contained in:
parent
a8eda192af
commit
6c3d2d0907
13 changed files with 210 additions and 185 deletions
|
|
@ -1,42 +1,22 @@
|
|||
project(vctest)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
add_executable(vctest ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
|
||||
|
||||
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
# Needed for header-only source util/ArgsReader.hpp
|
||||
target_include_directories(vctest PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
target_compile_options(
|
||||
vctest
|
||||
PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/W4>
|
||||
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wformat-nonliteral
|
||||
-Wcast-align
|
||||
-Wpointer-arith
|
||||
-Wundef
|
||||
-Wwrite-strings
|
||||
-Wno-unused-parameter
|
||||
>)
|
||||
|
||||
if(MSVC)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
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>")
|
||||
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)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
|
||||
endif()
|
||||
|
||||
target_include_directories(
|
||||
${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_DL_LIBS})
|
||||
target_link_options(vctest PRIVATE $<$<CXX_COMPILER_ID:GNU>:-no-pie>)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue