Improve CMakeLists.txt, Fix Windows builds

This commit is contained in:
MrLetsplay 2022-10-14 16:25:24 +02:00
parent 0944fc6206
commit 296b667268
4 changed files with 22 additions and 14 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
build/
build.win/
.vscode/

View File

@ -1,8 +1,7 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.13)
project(KekEngine VERSION 1.0)
option(BUILD_SHARED_LIBS "Build as a shared library" ON)
option(KEKENGINE_DEBUG "Build with debug information" OFF)
option(KEKENGINE_VR "Include VR support" OFF)
option(KEKENGINE_BUILD_KEKGAME "Build kekgame" OFF)
@ -12,7 +11,7 @@ if(UNIX)
endif()
if(WIN32)
set(KEKENGINE_TARGET_PLATFORM Windows)
set(BUILD_SHARED_LIBS OFF)
#set(BUILD_SHARED_LIBS OFF)
endif()
message("Build shared libs: ${BUILD_SHARED_LIBS}")
@ -56,9 +55,11 @@ add_custom_command(TARGET kekengine_res PRE_BUILD
tar cf ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources.tar ${KEKENGINE_RELATIVE_RESOURCE_FILES})
# libkekengine
add_library(kekengine ${KEKENGINE_SOURCE_FILES})
add_library(kekengine OBJECT ${KEKENGINE_SOURCE_FILES})
set_property(TARGET kekengine PROPERTY POSITION_INDEPENDENT_CODE 1)
add_dependencies(kekengine kekengine_res)
set_property(TARGET microtar PROPERTY POSITION_INDEPENDENT_CODE 1)
target_link_libraries(kekengine PUBLIC microtar)
if(UNIX)
@ -72,6 +73,7 @@ if(UNIX)
endif()
if(WIN32)
target_link_libraries(kekengine PUBLIC glfw3 glew32s opengl32)
target_compile_definitions(kekengine PUBLIC GLEW_STATIC)
endif()
if(${KEKENGINE_VR})
@ -93,6 +95,13 @@ if(${KEKENGINE_VR})
target_include_directories(kekengine PRIVATE "dependencies/openvr/headers")
endif()
add_library(kekengine_shared SHARED $<TARGET_OBJECTS:kekengine>)
target_link_libraries(kekengine_shared PUBLIC kekengine)
set_target_properties(kekengine_shared PROPERTIES OUTPUT_NAME kekengine)
add_library(kekengine_static STATIC $<TARGET_OBJECTS:kekengine>)
target_link_libraries(kekengine_static PUBLIC kekengine)
set_target_properties(kekengine_static PROPERTIES OUTPUT_NAME kekengine)
if(${KEKENGINE_BUILD_KEKGAME})
# kekgame resources
add_custom_target(kekgame_res ALL
@ -109,6 +118,6 @@ if(${KEKENGINE_BUILD_KEKGAME})
add_executable(kekgame ${KEKGAME_SOURCE_FILES})
add_dependencies(kekgame kekgame_res)
target_link_libraries(kekgame PUBLIC kekengine)
target_link_libraries(kekgame PUBLIC kekengine_static)
target_include_directories(kekgame PRIVATE "src/kekengine/include")
endif()

View File

@ -26,15 +26,15 @@ int main(int argc, char **argv) {
scene->addObject(test2);
}
//PointLight *light = new PointLight(glm::vec3(1), 1, 0, 1);
//scene->lights->add(light);
PointLight *light = new PointLight(glm::vec3(1), 1, 0, 1);
scene->lights->add(light);
//DirectionalLight *l = new DirectionalLight(glm::vec3(1), glm::vec3(1, -1, 1));
//scene->lights->add(l);
DirectionalLight *l = new DirectionalLight(glm::vec3(1), glm::vec3(1, -1, 1));
scene->lights->add(l);
SpotLight *spot = new SpotLight(glm::vec3(1), glm::vec3(0, 0, -1), 1, 0, 1, glm::radians(8.0f), glm::radians(15.0f));
spot->moveTo(glm::vec3(0, 0, 5));
scene->lights->add(spot);
//SpotLight *spot = new SpotLight(glm::vec3(1), glm::vec3(0, 0, -1), 1, 0, 1, glm::radians(8.0f), glm::radians(15.0f));
//spot->moveTo(glm::vec3(0, 0, 5));
//scene->lights->add(spot);
Engine::setActiveScene(scene);

View File

@ -6,8 +6,6 @@ set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_C_FLAGS -w)
set(CMAKE_CXX_FLAGS -w)
set(KEKENGINE_TARGET_PLATFORM Windows)
set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32/)
link_directories(windows/lib/)
include_directories(windows/include/)