[CMakeLists.txt] Small improvements.
This commit is contained in:
parent
9eed9ab135
commit
41a46ba13b
@ -13,6 +13,28 @@ if (WIN32)
|
|||||||
set(WIN_LIBRARIES_PATH "C:/Libraries")
|
set(WIN_LIBRARIES_PATH "C:/Libraries")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Compiler flags
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
set(DEBUG_GCC_FLAGS -g -Og -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
|
||||||
|
set(RELEASE_GCC_FLAGS -O3 -ffast-math)
|
||||||
|
set(RELWITHDEB_GCC_FLAGS -g -O3 -ffast-math -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Setting default build type
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
set(DEFAULT_BUILD_TYPE RelWithDebInfo)
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||||
|
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
|
||||||
|
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
|
||||||
|
|
||||||
|
# Set the possible values of build type for cmake-gui
|
||||||
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||||
|
endif()
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Packages
|
# Packages
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
@ -45,7 +45,8 @@ The long-term goal of this project is to provide a viable alternative to Minecra
|
|||||||
- [SFML](https://www.sfml-dev.org/) (only used for network)
|
- [SFML](https://www.sfml-dev.org/) (only used for network)
|
||||||
- [Lua](http://www.lua.org)
|
- [Lua](http://www.lua.org)
|
||||||
- _Linux users: Check your distribution repositories for packages._
|
- _Linux users: Check your distribution repositories for packages._
|
||||||
- Run `cmake . && make -j8`
|
- Run `cmake .`
|
||||||
|
- Run `make -j8`
|
||||||
- Run the server with `./server/openminer_server`
|
- Run the server with `./server/openminer_server`
|
||||||
- Run the client with `./client/openminer`
|
- Run the client with `./client/openminer`
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Set project name
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
set(PROJECT_NAME ${CMAKE_PROJECT_NAME})
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Get source files
|
# Get source files
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@ -12,41 +17,28 @@ endforeach(HEADER_FILE)
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Add executables
|
# Add executables
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_FILES})
|
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
|
||||||
add_dependencies(${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME}_common)
|
add_dependencies(${PROJECT_NAME} ${CMAKE_PROJECT_NAME}_common)
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -O3 -ffast-math)
|
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:DEBUG>:${DEBUG_GCC_FLAGS}>")
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -g -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
|
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:RELEASE>:${RELEASE_GCC_FLAGS}>")
|
||||||
|
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:RELWITHDEBINFO>:${RELWITHDEB_GCC_FLAGS}>")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -DDEBUG_ENABLED)
|
target_compile_options(${PROJECT_NAME} PRIVATE -DDEBUG_ENABLED)
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -DGLM_FORCE_RADIANS)
|
target_compile_options(${PROJECT_NAME} PRIVATE -DGLM_FORCE_RADIANS)
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -DSOL_CHECK_ARGUMENTS
|
target_compile_options(${PROJECT_NAME} PRIVATE -DSOL_CHECK_ARGUMENTS -DSOL_PRINT_ERRORS=0)
|
||||||
# -DSOL_SAFE_USERTYPE=1
|
|
||||||
# -DSOL_SAFE_REFERENCES=1
|
|
||||||
# -DSOL_SAFE_FUNCTION_CALLS=1
|
|
||||||
# -DSOL_SAFE_FUNCTION=1
|
|
||||||
# -DSOL_SAFE_NUMERICS=1
|
|
||||||
# -DSOL_SAFE_GETTER=1
|
|
||||||
-DSOL_PRINT_ERRORS=1
|
|
||||||
)
|
|
||||||
|
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
target_link_options(${CMAKE_PROJECT_NAME} PRIVATE -static-libstdc++ -static-libgcc -mconsole)
|
target_link_options(${PROJECT_NAME} PRIVATE -static-libstdc++ -static-libgcc -mconsole)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
# target_compile_options(${PROJECT_NAME} PRIVATE -pg)
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
# target_link_options(${PROJECT_NAME} PRIVATE -pg)
|
||||||
else()
|
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -std=c++14)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -pg)
|
|
||||||
# target_link_options(${CMAKE_PROJECT_NAME} PRIVATE -pg)
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Link options
|
# Link options
|
||||||
@ -55,7 +47,7 @@ if (UNIX)
|
|||||||
set (UNIX_LIBS -ldl)
|
set (UNIX_LIBS -ldl)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_link_libraries(${CMAKE_PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
${GAMEKIT_LIBRARIES}
|
${GAMEKIT_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${SDL2_LIBRARIES}
|
${SDL2_LIBRARIES}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Set project name
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
set(PROJECT_NAME ${CMAKE_PROJECT_NAME}_common)
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Get source files
|
# Get source files
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@ -12,35 +17,22 @@ endforeach(HEADER_FILE)
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Add library
|
# Add library
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
add_library(${CMAKE_PROJECT_NAME}_common STATIC ${SOURCE_FILES})
|
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -O3 -ffast-math)
|
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:DEBUG>:${DEBUG_GCC_FLAGS}>")
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -g -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
|
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:RELEASE>:${RELEASE_GCC_FLAGS}>")
|
||||||
|
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:RELWITHDEBINFO>:${RELWITHDEB_GCC_FLAGS}>")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -DDEBUG_ENABLED)
|
target_compile_options(${PROJECT_NAME} PRIVATE -DDEBUG_ENABLED)
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -DGLM_FORCE_RADIANS)
|
target_compile_options(${PROJECT_NAME} PRIVATE -DGLM_FORCE_RADIANS)
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -DSOL_CHECK_ARGUMENTS
|
target_compile_options(${PROJECT_NAME} PRIVATE -DSOL_CHECK_ARGUMENTS -DSOL_PRINT_ERRORS=0)
|
||||||
# -DSOL_SAFE_USERTYPE=1
|
|
||||||
# -DSOL_SAFE_REFERENCES=1
|
|
||||||
# -DSOL_SAFE_FUNCTION_CALLS=1
|
|
||||||
# -DSOL_SAFE_FUNCTION=1
|
|
||||||
# -DSOL_SAFE_NUMERICS=1
|
|
||||||
# -DSOL_SAFE_GETTER=1
|
|
||||||
-DSOL_PRINT_ERRORS=1
|
|
||||||
)
|
|
||||||
|
|
||||||
if(MSVC)
|
# target_compile_options(${PROJECT_NAME} PRIVATE -pg)
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
|
||||||
else()
|
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -std=c++14)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -pg)
|
target_link_libraries(${PROJECT_NAME} sfml-system sfml-network)
|
||||||
|
|
||||||
target_link_libraries(${CMAKE_PROJECT_NAME}_common sfml-system sfml-network)
|
|
||||||
|
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
-- =====================================================================================
|
-- =====================================================================================
|
||||||
--
|
--
|
||||||
|
|
||||||
print("Hello from Lua!")
|
|
||||||
|
|
||||||
-- FIXME
|
-- FIXME
|
||||||
SCREEN_WIDTH = 1600
|
SCREEN_WIDTH = 1600
|
||||||
SCREEN_HEIGHT = 1050
|
SCREEN_HEIGHT = 1050
|
||||||
@ -84,4 +82,3 @@ function show_inventory(client)
|
|||||||
|
|
||||||
gui:show(client)
|
gui:show(client)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Set project name
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
set(PROJECT_NAME ${PROJECT_NAME}_server)
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Get source files
|
# Get source files
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@ -12,41 +17,28 @@ endforeach(HEADER_FILE)
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Add executables
|
# Add executables
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
add_executable(${CMAKE_PROJECT_NAME}_server ${SOURCE_FILES})
|
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
|
||||||
add_dependencies(${CMAKE_PROJECT_NAME}_server ${CMAKE_PROJECT_NAME}_common)
|
add_dependencies(${PROJECT_NAME} ${CMAKE_PROJECT_NAME}_common)
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
if (NOT MSVC)
|
if (NOT MSVC)
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -O3 -ffast-math)
|
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:DEBUG>:${DEBUG_GCC_FLAGS}>")
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -g -Wall -Wextra -Wfatal-errors -Wno-variadic-macros)
|
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:RELEASE>:${RELEASE_GCC_FLAGS}>")
|
||||||
|
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:RELWITHDEBINFO>:${RELWITHDEB_GCC_FLAGS}>")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -DDEBUG_ENABLED)
|
target_compile_options(${PROJECT_NAME} PRIVATE -DDEBUG_ENABLED)
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -DGLM_FORCE_RADIANS)
|
target_compile_options(${PROJECT_NAME} PRIVATE -DGLM_FORCE_RADIANS)
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -DSOL_CHECK_ARGUMENTS
|
target_compile_options(${PROJECT_NAME} PRIVATE -DSOL_CHECK_ARGUMENTS -DSOL_PRINT_ERRORS=0)
|
||||||
# -DSOL_SAFE_USERTYPE=1
|
|
||||||
# -DSOL_SAFE_REFERENCES=1
|
|
||||||
# -DSOL_SAFE_FUNCTION_CALLS=1
|
|
||||||
# -DSOL_SAFE_FUNCTION=1
|
|
||||||
# -DSOL_SAFE_NUMERICS=1
|
|
||||||
# -DSOL_SAFE_GETTER=1
|
|
||||||
-DSOL_PRINT_ERRORS=1
|
|
||||||
)
|
|
||||||
|
|
||||||
if(MINGW)
|
if(MINGW)
|
||||||
target_link_options(${CMAKE_PROJECT_NAME}_server PRIVATE -static-libstdc++ -static-libgcc -mconsole)
|
target_link_options(${PROJECT_NAME} PRIVATE -static-libstdc++ -static-libgcc -mconsole)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
# target_compile_options(${PROJECT_NAME} PRIVATE -pg)
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
# target_link_options(${PROJECT_NAME} PRIVATE -pg)
|
||||||
else()
|
|
||||||
target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -std=c++14)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -pg)
|
|
||||||
# target_link_options(${CMAKE_PROJECT_NAME}_server PRIVATE -pg)
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Link options
|
# Link options
|
||||||
@ -55,7 +47,7 @@ if (UNIX)
|
|||||||
set (UNIX_LIBS -ldl)
|
set (UNIX_LIBS -ldl)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
target_link_libraries(${CMAKE_PROJECT_NAME}_server
|
target_link_libraries(${PROJECT_NAME}
|
||||||
${GAMEKIT_LIBRARIES}
|
${GAMEKIT_LIBRARIES}
|
||||||
${OPENGL_LIBRARIES}
|
${OPENGL_LIBRARIES}
|
||||||
${SDL2_LIBRARIES}
|
${SDL2_LIBRARIES}
|
||||||
|
@ -61,7 +61,7 @@ class Server {
|
|||||||
void handleNewConnections();
|
void handleNewConnections();
|
||||||
void handleClientMessages();
|
void handleClientMessages();
|
||||||
|
|
||||||
bool m_isRunning = true;
|
bool m_isRunning = false;
|
||||||
|
|
||||||
ServerInfo m_info;
|
ServerInfo m_info;
|
||||||
|
|
||||||
|
@ -49,20 +49,21 @@ void ServerApplication::init() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
m_scriptEngine.lua()["openminer"] = &m_luaCore;
|
m_scriptEngine.lua()["openminer"] = &m_luaCore;
|
||||||
// m_scriptEngine.lua().script("init()");
|
m_scriptEngine.lua().safe_script_file("mods/default/init.lua");
|
||||||
}
|
}
|
||||||
catch (const sol::error &e) {
|
catch (const sol::error &e) {
|
||||||
std::cerr << e.what() << std::endl;
|
std::cerr << e.what() << std::endl;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scriptEngine.lua().safe_script_file("mods/default/init.lua");
|
|
||||||
|
|
||||||
m_server.init(m_port);
|
m_server.init(m_port);
|
||||||
m_server.setRunning(true);
|
m_server.setRunning(true);
|
||||||
|
|
||||||
m_serverCommandHandler.setupCallbacks();
|
m_serverCommandHandler.setupCallbacks();
|
||||||
|
|
||||||
m_world.setServer(&m_serverCommandHandler);
|
m_world.setServer(&m_serverCommandHandler);
|
||||||
|
|
||||||
|
std::cout << "Server is running on localhost:" << m_port << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::update() {
|
void ServerApplication::update() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user