Improved linux/cmake template
This commit is contained in:
committed by
Matteo De Carlo
parent
ef15e99cd5
commit
4588f45271
@@ -1,6 +1,16 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
project(Template_Linux)
|
||||
|
||||
# if the engine is installed system-wise,
|
||||
# you can set INSTALLED_ENGINE to ON
|
||||
# moving your project folder wherever you want
|
||||
set(INSTALLED_ENGINE OFF)
|
||||
# you may also want to remove the copy mechanism of the startup.lua file
|
||||
|
||||
if (${INSTALLED_ENGINE})
|
||||
find_package(WickedEngine REQUIRED)
|
||||
endif()
|
||||
|
||||
set (SOURCE_FILES
|
||||
main.cpp
|
||||
stdafx.h
|
||||
@@ -11,11 +21,28 @@ set(LIB_DXCOMPILER "libdxcompiler.so")
|
||||
add_executable(Template_Linux ${SOURCE_FILES})
|
||||
|
||||
target_link_libraries(Template_Linux PUBLIC
|
||||
WickedEngine
|
||||
# These are cmake generator expressions. They seem more dauting than they are
|
||||
# Basically if the variable is ON it will give WickedEngine,
|
||||
# if it's off, it will give WickedEngine::WickedEngine
|
||||
$<$<NOT:$<BOOL:${INSTALLED_ENGINE}>>:WickedEngine>
|
||||
$<$<BOOL:${INSTALLED_ENGINE}>:WickedEngine::WickedEngine>
|
||||
)
|
||||
|
||||
if (${INSTALLED_ENGINE})
|
||||
get_property(LIBDXCOMPILER_PATH
|
||||
TARGET WickedEngine::dxcompiler
|
||||
PROPERTY IMPORTED_LOCATION)
|
||||
get_filename_component(WICKED_LIBFOLDER ${LIBDXCOMPILER_PATH} DIRECTORY)
|
||||
set(STARTUP_LUA "${WICKED_LIBFOLDER}/Editor/startup.lua")
|
||||
else()
|
||||
set(LIBDXCOMPILER_PATH "${CMAKE_SOURCE_DIR}/WickedEngine/${LIB_DXCOMPILER}")
|
||||
set(STARTUP_LUA "${CMAKE_SOURCE_DIR}/Editor/startup.lua")
|
||||
endif()
|
||||
message("libdxcompiler found at ${LIBDXCOMPILER_PATH}")
|
||||
message("startup lua found at ${STARTUP_LUA}")
|
||||
|
||||
add_custom_command(
|
||||
TARGET Template_Linux POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/WickedEngine/${LIB_DXCOMPILER} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/Editor/startup.lua ${CMAKE_CURRENT_BINARY_DIR}/startup.lua
|
||||
)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LIBDXCOMPILER_PATH} ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${STARTUP_LUA} ${CMAKE_CURRENT_BINARY_DIR}/startup.lua
|
||||
)
|
||||
|
||||
@@ -43,6 +43,9 @@ int sdl_loop(wi::Application &application)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
wi::Application application;
|
||||
#ifdef WickedEngine_SHADER_DIR
|
||||
wi::renderer::SetShaderSourcePath(WickedEngine_SHADER_DIR);
|
||||
#endif
|
||||
|
||||
application.infoDisplay.active = true;
|
||||
application.infoDisplay.watermark = true;
|
||||
@@ -65,4 +68,4 @@ int main(int argc, char *argv[])
|
||||
SDL_Quit();
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user