2020-09-10 15:42:10 +00:00
|
|
|
cmake_minimum_required(VERSION 3.11)
|
2020-07-06 19:18:29 +00:00
|
|
|
project (univerxel VERSION 0.0.1)
|
|
|
|
|
2020-08-01 21:31:01 +00:00
|
|
|
option(PROFILING "Build with profiling" 0)
|
|
|
|
option(FIXED_WINDOW "Lock window size: Force floating on i3" 0)
|
2020-09-24 12:11:04 +00:00
|
|
|
set(SIMD_LEVEL "avx2" CACHE STRING "SIMD processor acceleration (sse2, sse4.1, avx2, avx512f)")
|
|
|
|
option(USE_FMA "Use fma" 1)
|
2020-07-18 12:54:07 +00:00
|
|
|
|
2020-07-06 19:18:29 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
|
2020-08-07 17:08:02 +00:00
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
2020-07-06 19:18:29 +00:00
|
|
|
|
|
|
|
find_program(CCACHE_FOUND ccache)
|
|
|
|
if(CCACHE_FOUND)
|
|
|
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
|
|
|
endif(CCACHE_FOUND)
|
|
|
|
|
2020-09-24 12:11:04 +00:00
|
|
|
add_subdirectory("include/glfw")
|
2020-09-13 09:30:48 +00:00
|
|
|
add_subdirectory("include/glm")
|
2020-09-22 20:37:09 +00:00
|
|
|
add_subdirectory("include/enet")
|
2020-09-24 12:11:04 +00:00
|
|
|
add_subdirectory("include/zstd")
|
|
|
|
set(LINKED_LIBS glfw pthread dl
|
|
|
|
glm::glm_static enet::enet_static zstd::zstd_static)
|
2020-07-06 19:18:29 +00:00
|
|
|
|
2020-07-31 17:09:44 +00:00
|
|
|
file(GLOB_RECURSE SOURCES "src/*/*.cpp")
|
2020-09-13 09:30:48 +00:00
|
|
|
file(GLOB INCLUDE_SOURCES
|
|
|
|
"include/imgui/*.cpp"
|
|
|
|
"include/FastNoiseSIMD/*.cpp"
|
|
|
|
"include/tracy/TracyClient.cpp"
|
|
|
|
"include/meshoptimizer/*.cpp"
|
|
|
|
"include/gl3w/gl3w.c"
|
|
|
|
)
|
2020-07-30 16:35:13 +00:00
|
|
|
set(INCLUDE_LIBS
|
2020-09-13 09:30:48 +00:00
|
|
|
"include/imgui"
|
2020-07-30 16:35:13 +00:00
|
|
|
"include/FastNoiseSIMD"
|
|
|
|
"include/toml++"
|
|
|
|
"include/robin_hood"
|
2020-07-31 22:11:08 +00:00
|
|
|
"include/libguarded"
|
2020-08-07 17:08:02 +00:00
|
|
|
"include/tracy"
|
2020-08-08 11:01:07 +00:00
|
|
|
"include/meshoptimizer"
|
2020-09-13 09:30:48 +00:00
|
|
|
"include/gl3w"
|
2020-07-30 16:35:13 +00:00
|
|
|
)
|
2020-07-06 19:18:29 +00:00
|
|
|
|
2020-07-31 17:09:44 +00:00
|
|
|
add_executable(univerxel "src/main.cpp" ${SOURCES} ${INCLUDE_SOURCES})
|
2020-07-06 19:18:29 +00:00
|
|
|
target_compile_features(univerxel PUBLIC cxx_std_17)
|
2020-07-30 16:35:13 +00:00
|
|
|
target_link_libraries(univerxel ${LINKED_LIBS})
|
|
|
|
target_include_directories(univerxel PRIVATE ${INCLUDE_LIBS})
|
2020-08-07 17:08:02 +00:00
|
|
|
target_compile_definitions(univerxel PRIVATE FIXED_WINDOW=${FIXED_WINDOW} HN_USE_FILESYSTEM=1)
|
2020-09-13 13:12:04 +00:00
|
|
|
if(PROFILING)
|
|
|
|
add_compile_definitions(TRACY_ENABLE=1)
|
2020-08-07 17:08:02 +00:00
|
|
|
endif(PROFILING)
|
2020-09-24 12:11:04 +00:00
|
|
|
if(SIMD_LEVEL EQUAL "avx2")
|
|
|
|
add_compile_definitions(FN_COMPILE_AVX2=1)
|
|
|
|
elseif(SIMD_LEVEL EQUAL "avx512f")
|
|
|
|
add_compile_definitions(FN_COMPILE_AVX512=1)
|
|
|
|
endif()
|
|
|
|
add_definitions(-m${SIMD_LEVEL})
|
|
|
|
if(USE_FMA)
|
|
|
|
add_definitions(-mfma)
|
|
|
|
endif(USE_FMA)
|
|
|
|
|
2020-08-07 17:08:02 +00:00
|
|
|
|
2020-09-10 15:42:10 +00:00
|
|
|
file(COPY resource/content DESTINATION ${CMAKE_BINARY_DIR})
|
2020-07-06 19:18:29 +00:00
|
|
|
|
|
|
|
# Docs
|
|
|
|
add_custom_target(docs
|
|
|
|
COMMAND doxygen ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
COMMENT "Build doc."
|
2020-07-31 17:09:44 +00:00
|
|
|
)
|
|
|
|
|
2020-08-30 16:35:45 +00:00
|
|
|
# Builtin models
|
|
|
|
file(GLOB_RECURSE MCT_SOURCES "src/model_contouring.cpp" "src/*/*.cpp")
|
|
|
|
add_executable(model_contouring EXCLUDE_FROM_ALL ${MCT_SOURCES} ${INCLUDE_SOURCES})
|
|
|
|
target_compile_features(model_contouring PUBLIC cxx_std_17)
|
|
|
|
target_link_libraries(model_contouring ${LINKED_LIBS})
|
|
|
|
target_include_directories(model_contouring PRIVATE ${INCLUDE_LIBS})
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/content/model.ivb"
|
|
|
|
COMMAND "${CMAKE_BINARY_DIR}/model_contouring" DEPENDS model_contouring)
|
2020-09-24 12:11:04 +00:00
|
|
|
add_custom_target(render_models DEPENDS "${CMAKE_BINARY_DIR}/content/model.ivb")
|