2022-05-14 18:24:20 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
2022-01-25 03:46:29 +00:00
|
|
|
project(Laika)
|
|
|
|
|
2022-02-14 06:22:36 +00:00
|
|
|
set(CMAKE_C_STANDARD 11)
|
2022-01-30 07:20:47 +00:00
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
|
2022-04-06 06:07:16 +00:00
|
|
|
execute_process(COMMAND git rev-parse --short HEAD OUTPUT_VARIABLE GIT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
2022-01-25 03:46:29 +00:00
|
|
|
# Set the project as the default startup project for VS
|
2022-03-15 17:57:58 +00:00
|
|
|
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT LaikaLib)
|
2022-01-25 03:46:29 +00:00
|
|
|
|
2022-01-27 19:36:36 +00:00
|
|
|
# include our cmake modules
|
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake-modules" ${CMAKE_MODULE_PATH})
|
|
|
|
|
2022-01-25 03:46:29 +00:00
|
|
|
# Output binaries to the bin folder in the source directory
|
2022-04-04 20:54:41 +00:00
|
|
|
if(WIN32)
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/winbin)
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/winbin)
|
|
|
|
else()
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
|
|
|
endif()
|
2022-01-24 03:28:16 +00:00
|
|
|
|
2022-01-29 23:16:29 +00:00
|
|
|
#find_package(Sanitizers)
|
2022-01-29 23:00:44 +00:00
|
|
|
|
2022-01-27 19:36:36 +00:00
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2022-03-15 18:24:29 +00:00
|
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
|
|
endif ()
|
2022-01-27 19:36:36 +00:00
|
|
|
|
2022-01-29 23:00:44 +00:00
|
|
|
string(TOLOWER ${CMAKE_BUILD_TYPE} RAWCMAKEBUILDTYPE)
|
|
|
|
message(STATUS "CMAKE_BUILD_TYPE: " ${RAWCMAKEBUILDTYPE})
|
|
|
|
if(RAWCMAKEBUILDTYPE STREQUAL "debug")
|
2022-06-05 20:51:18 +00:00
|
|
|
set(LAIKA_DEBUG_BUILD on)
|
2022-05-14 18:24:20 +00:00
|
|
|
if(WIN32)
|
|
|
|
# statically link debug libs for windows
|
|
|
|
message(STATUS "Adding MSVC Debug libs...")
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
|
|
|
|
else()
|
|
|
|
message(STATUS "Adding sanitizer...")
|
|
|
|
#set(SANITIZE_ADDRESS TRUE)
|
|
|
|
#add_sanitizers(LaikaLib LaikaBot LaikaCNC)
|
|
|
|
|
|
|
|
# bug in FindSanitizer.cmake ??? idfk, i'll investigate l8tr
|
|
|
|
add_compile_options(-fsanitize=address)
|
|
|
|
add_link_options(-fsanitize=address)
|
|
|
|
endif ()
|
|
|
|
else()
|
2022-06-05 20:51:18 +00:00
|
|
|
set(LAIKA_DEBUG_BUILD off)
|
2022-05-14 18:24:20 +00:00
|
|
|
# statically link non-debug libs
|
|
|
|
if(WIN32)
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
|
|
|
|
endif ()
|
2022-01-29 23:00:44 +00:00
|
|
|
endif ()
|
|
|
|
|
2022-03-14 02:48:09 +00:00
|
|
|
# include libsodium
|
|
|
|
set(SODIUM_DISABLE_TESTS ON)
|
|
|
|
set(SODIUM_MINIMAL ON)
|
|
|
|
set(SODIUM_STATIC ON)
|
2022-05-19 06:42:40 +00:00
|
|
|
add_subdirectory(libsodium)
|
|
|
|
|
2022-06-27 23:20:23 +00:00
|
|
|
# ===================================== [[ CONFIG DEFAULTS ]] =====================================
|
2022-05-19 06:42:40 +00:00
|
|
|
|
|
|
|
set(LAIKA_VMBOXCONFIG ${CMAKE_SOURCE_DIR}/lib/include/lboxconfig.h)
|
|
|
|
|
|
|
|
# DO NOT USE THESE KEYS, TESTING ONLY (TODO: make vmboxgen auto gen these)
|
|
|
|
if(NOT LAIKA_PUBKEY)
|
|
|
|
set(LAIKA_PUBKEY "40d5534aca77d1f5ec2bbe79dd9d0f52a78148918f95814404cefe97c34c5c27")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if(NOT LAIKA_PRIVKEY)
|
|
|
|
set(LAIKA_PRIVKEY "90305aa77023d1c1e03265c3b6af046eb58d6ec8ba650b0dffed01379feab8cc")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if(NOT LAIKA_CNC_IP)
|
|
|
|
set(LAIKA_CNC_IP "127.0.0.1")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if(NOT LAIKA_CNC_PORT)
|
|
|
|
set(LAIKA_CNC_PORT "13337")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
# version details
|
|
|
|
set(LAIKA_VERSION_MAJOR 0)
|
|
|
|
set(LAIKA_VERSION_MINOR 3)
|
|
|
|
|
|
|
|
message(STATUS "Building config file...")
|
|
|
|
configure_file(${CMAKE_SOURCE_DIR}/lib/include/lconfig.h.in ${CMAKE_SOURCE_DIR}/lib/include/lconfig.h)
|
|
|
|
|
|
|
|
# config vm boxes
|
|
|
|
add_subdirectory(tools/vmboxgen)
|
|
|
|
|
2022-06-27 23:20:23 +00:00
|
|
|
# ====================================== [[ BUILD TOOLING ]] ======================================
|
2022-03-14 02:48:09 +00:00
|
|
|
|
2022-01-27 19:36:36 +00:00
|
|
|
# compile laikalib, tools, cnc & bot
|
2022-01-24 03:28:16 +00:00
|
|
|
add_subdirectory(lib)
|
2022-01-27 19:36:36 +00:00
|
|
|
add_subdirectory(tools)
|
2022-03-14 02:54:47 +00:00
|
|
|
|
|
|
|
# these subprojects don't support windows (sorry)
|
2022-03-17 23:22:26 +00:00
|
|
|
add_subdirectory(bot) # windows support Soon:tm:
|
2022-03-15 17:57:58 +00:00
|
|
|
if(NOT WIN32 AND (UNIX AND NOT APPLE))
|
2022-03-14 02:54:47 +00:00
|
|
|
add_subdirectory(cnc)
|
|
|
|
add_subdirectory(shell)
|
2022-03-15 18:24:29 +00:00
|
|
|
endif ()
|