Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24m06b - Creation Update #34

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
eaf4d17
fix component dispatch and add test
AstroAir May 27, 2024
81173f7
sync web client
AstroAir May 28, 2024
79dbb1f
update lithium-web
AstroAir May 28, 2024
ddf1b98
update atom-component
AstroAir May 31, 2024
8b13534
update
AstroAir Jun 1, 2024
6d5e012
update unittest
AstroAir Jun 1, 2024
0e672fd
update atom-function and test
AstroAir Jun 2, 2024
e176f09
small update
AstroAir Jun 3, 2024
779848d
fix class member registration
AstroAir Jun 3, 2024
07fd3cc
remove carbon script for no need
AstroAir Jun 4, 2024
c940e98
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 4, 2024
b530257
refactor(config): update goto_center.json with new function and step …
AstroAir Jun 8, 2024
6d2c120
refactor: :hammer: 重构atom-system模块
AstroAir Jun 10, 2024
dc8fd4a
update
AstroAir Jun 13, 2024
73f785a
update not finished
AstroAir Jun 16, 2024
6dbc57a
feat(lithium): add task module and update astrometry and indi modules
AstroAir Jun 23, 2024
99dacdd
loading.drawio
AstroAir Jun 25, 2024
d5f3307
feat(greetings): add check for already greeted issues and PRs
AstroAir Jun 26, 2024
655d09e
update not finshed
AstroAir Jun 27, 2024
d66ce00
update not finished
AstroAir Jun 28, 2024
e05a5db
update not finished
AstroAir Jul 1, 2024
89e43d7
Separate web client to a separate repository
AstroAir Jul 5, 2024
fcde935
remove drivers and oatpp server
AstroAir Jul 6, 2024
2727ec2
add oatpp server template and prepare to modify
AstroAir Jul 6, 2024
b704175
update not finished
AstroAir Jul 6, 2024
700deff
update not finished
AstroAir Jul 10, 2024
12c7458
update not finished
AstroAir Jul 14, 2024
fe63f8f
udpate not finished
AstroAir Jul 16, 2024
9684fc0
fix compilation bugs
AstroAir Jul 16, 2024
c510b36
fix atom.component.test
AstroAir Jul 18, 2024
b6c0e5b
fix atom.utils but still hava problems
AstroAir Jul 19, 2024
3a863dc
add lithium.client.astap without test
AstroAir Jul 20, 2024
766e8ec
add lithium.client.astrometry without test
AstroAir Jul 20, 2024
b891e40
update xmake build but not finished
AstroAir Jul 20, 2024
45e939d
update
AstroAir Jul 22, 2024
110f426
udpate not finish
AstroAir Jul 24, 2024
049e489
update not finished
AstroAir Jul 24, 2024
9d7193f
fix build on windows
AstroAir Jul 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
297 changes: 116 additions & 181 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,45 @@
# License: GPL3

cmake_minimum_required(VERSION 3.20)
project(Lithium VERSION 1.0.0 LANGUAGES C CXX)

project(Lithium)
enable_language(C CXX)
# Set project options
option(ENABLE_ASYNC "Enable Async Server Mode" ON)
option(ENABLE_NATIVE_SERVER "Enable to use INDI native server" OFF)
option(ENABLE_DEBUG "Enable Debug Mode" OFF)
option(ENABLE_FASHHASH "Enable Using emhash8 as fast hash map" OFF)
option(ENABLE_WEB_SERVER "Enable Web Server" ON)
option(ENABLE_WEB_CLIENT "Enable Web Client" ON)

if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
if(POLICY CMP0043)
cmake_policy(SET CMP0043 NEW)
endif()
# Set compile definitions based on options
if(ENABLE_ASYNC)
add_compile_definitions(ENABLE_ASYNC_FLAG=1)
endif()
if(ENABLE_DEBUG)
add_compile_definitions(ENABLE_DEBUG_FLAG=1)
endif()
if(ENABLE_NATIVE_SERVER)
add_compile_definitions(ENABLE_NATIVE_SERVER_FLAG=1)
endif()
if(ENABLE_FASHHASH)
add_compile_definitions(ENABLE_FASHHASH_FLAG=1)
endif()
if(ENABLE_WEB_SERVER)
add_compile_definitions(ENABLE_WEB_SERVER_FLAG=1)
endif()
if(ENABLE_WEB_CLIENT)
add_compile_definitions(ENABLE_WEB_CLIENT_FLAG=1)
endif()

# root directory of the project
# Set policies
if(POLICY CMP0003)
cmake_policy(SET CMP0003 NEW)
endif()
if(POLICY CMP0043)
cmake_policy(SET CMP0043 NEW)
endif()

# Set project directories
set(Lithium_PROJECT_ROOT_DIR ${CMAKE_SOURCE_DIR})
set(lithium_src_dir ${Lithium_PROJECT_ROOT_DIR}/src)
set(lithium_module_dir ${lithium_src_dir}/atom)
Expand All @@ -29,155 +56,39 @@ set(lithium_task_dir ${lithium_src_dir}/task)
add_custom_target(CmakeAdditionalFiles
SOURCES
${lithium_src_dir}/../cmake_modules/compiler_options.cmake)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules/")

# compiler options
include(cmake_modules/compiler_options.cmake)

include(GNUInstallDirs)
include(FeatureSummary)
include(CheckSymbolExists)
include(CheckIncludeFileCXX)

# Clang Format support
if(UNIX OR APPLE)
set(FORMAT_CODE OFF CACHE BOOL "Enable Clang Format")

if(FORMAT_CODE MATCHES ON)
FILE(GLOB_RECURSE ALL_SOURCE_FILES *.c *.cpp *.h)

FOREACH(SOURCE_FILE ${ALL_SOURCE_FILES})
STRING(FIND ${SOURCE_FILE} ${CMAKE_SOURCE_DIR} DIR_FOUND)

if(NOT ${DIR_FOUND} EQUAL 0)
LIST(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif()
ENDFOREACH()

FIND_PROGRAM(CLANGFORMAT_EXE NAMES clang-format-5.0)

if(CLANGFORMAT_EXE)
ADD_CUSTOM_TARGET(clang-format COMMAND ${CLANGFORMAT_EXE} -style=file -i ${ALL_SOURCE_FILES})
endif()
endif()
endif()

#################################################################################
#
# Lithium version

set(CMAKE_LITHIUM_VERSION_MAJOR 1)
set(CMAKE_LITHIUM_VERSION_MINOR 0)
set(CMAKE_LITHIUM_VERSION_RELEASE 0)

set(LITHIUM_SOVERSION ${CMAKE_LITHIUM_VERSION_MAJOR})
set(CMAKE_LITHIUM_VERSION_STRING "${CMAKE_LITHIUM_VERSION_MAJOR}.${CMAKE_LITHIUM_VERSION_MINOR}.${CMAKE_LITHIUM_VERSION_RELEASE}")
set(LITHIUM_VERSION ${CMAKE_LITHIUM_VERSION_MAJOR}.${CMAKE_LITHIUM_VERSION_MINOR}.${CMAKE_LITHIUM_VERSION_RELEASE})

if(APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
endif(APPLE)

#################################################################################
#
# Lithium includes

# Include directories
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/libs/)
include_directories(${CMAKE_SOURCE_DIR}/driverlibs/)
include_directories(${lithium_src_dir})
include_directories(${lithium_module_dir})
include_directories(${lithium_src_dir})
include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp)
include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-swagger)
include_directories(${CMAKE_SOURCE_DIR}/libs/oatpp-websocket)

# Find packages
find_package(OpenSSL REQUIRED)
if(OpenSSL_FOUND)
message("-- Found OpenSSL ${OPENSSL_VERSION}: ${OPENSSL_LIBRARIES}")
else()
message("-- OpenSSL Not Found")
endif()

find_package(ZLIB REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(fmt REQUIRED)

#################################################################################
#
# Subdirectories of Lithium

# Build all dependencies
# 构建所有需要的依赖库
add_subdirectory(libs/)
# Configure config.h
configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)

# Build Atom core library
# 构建Atom核心库
# Add subdirectories
add_subdirectory(libs)
add_subdirectory(${lithium_module_dir})

# 内置的模组
include_directories(modules)
add_subdirectory(modules)

add_subdirectory(driver)

add_subdirectory(${lithium_src_dir}/carbon)
add_subdirectory(${lithium_src_dir}/config)
add_subdirectory(${lithium_src_dir}/task)
add_subdirectory(tests)

#################################################################################
#
# General defines for compatibility across different platforms
if(UNIX AND NOT APPLE)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr CACHE PATH "Lithium install path" FORCE)
endif()
endif()

set(USE_FOLDERS TRUE)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

option(ENABLE_ASYNC "Enable Async Server Mode" ON)
option(ENABLE_NATIVE_SERVER "Enable to use INDI native server" OFF)
option(ENABLE_DEBUG "Enable Debug Mode" OFF)

option(ENABLE_FASHHASH "Enable Using emhash8 as fast hash map" OFF)
option(ENABLE_WEB_SERVER "Enable Web Server" ON)
option(ENABLE_WEB_CLIENT "Enable Web Client" ON)

if(ENABLE_ASYNC)
set(ENABLE_ASYNC_FLAG "1")
endif()
if(ENABLE_DEBUG)
set(ENABLE_DEBUG_FLAG "1")
endif()
if(ENABLE_NATIVE_SERVER)
set(ENABLE_NATIVE_SERVER_FLAG "1")
endif()
if(ENABLE_FASHHASH)
set(ENABLE_FASHHASH_FLAG "1")
endif()
if(ENABLE_WEB_SERVER)
set(ENABLE_WEB_SERVER_FLAG "1")
endif()
if(ENABLE_WEB_CLIENT)
set(ENABLE_WEB_CLIENT_FLAG "1")
endif()

configure_file(config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})

#################################################################################

if(WIN32)
set(CMAKE_INSTALL_PREFIX "C:/Program Files/LithiumServer")
elseif(LINUX)
set(CMAKE_INSTALL_PREFIX "/usr/lithium")
endif()

# Set source files
set(component_module
${lithium_component_dir}/addons.cpp
${lithium_component_dir}/compiler.cpp
Expand All @@ -195,76 +106,100 @@ set(debug_module
${lithium_src_dir}/debug/terminal.cpp
${lithium_src_dir}/debug/suggestion.cpp
${lithium_src_dir}/debug/command.cpp
${lithium_src_dir}/debug/console.cpp
)

set(script_module
${lithium_src_dir}/script/manager.cpp
${lithium_src_dir}/script/custom/sys.cpp
${lithium_src_dir}/script/custom/config.cpp

${lithium_src_dir}/script/sheller.cpp

${lithium_src_dir}/script/carbon.cpp
)

set(task_module
${lithium_task_dir}/manager.cpp
${lithium_task_dir}/generator.cpp
${lithium_task_dir}/container.cpp
${lithium_task_dir}/tick.cpp
${lithium_task_dir}/loader.cpp
${lithium_task_dir}/list.cpp
${lithium_task_dir}/pool.cpp
# ${lithium_task_dir}/chekcer.cpp
)

set(Lithium_module
${lithium_src_dir}/LithiumApp.cpp

${lithium_src_dir}/utils/constant.cpp
)

#################################################################################
# Main

add_library(lithium_server-library STATIC ${component_module} ${config_module} ${debug_module} ${module_module} ${device_module} ${task_module} ${script_module} ${Lithium_module})
target_link_libraries(lithium_server-library loguru)
target_link_libraries(lithium_server-library atom-component)
add_executable(lithium_server ${lithium_src_dir}/App.cpp)
target_link_directories(lithium_server PUBLIC ${CMAKE_BINARY_DIR}/libs)
# Build lithium_server-library
add_library(lithium_server-library STATIC
${component_module}
${config_module}
${debug_module}
${script_module}
${Lithium_module}
)

target_link_libraries(lithium_server lithium_server-library)
target_link_libraries(lithium_server lithium_webserver)
target_link_libraries(lithium_server oatpp-websocket oatpp-swagger oatpp-openssl oatpp-zlib oatpp)
target_link_libraries(lithium_server loguru)
target_link_libraries(lithium_server libzippp)
target_link_libraries(lithium_server atomstatic)
target_link_libraries(lithium_server carbon)
target_link_libraries(lithium_server fmt::fmt)
target_link_libraries(lithium_server-library
PUBLIC
loguru
atom-component
)

target_compile_definitions(lithium_server PRIVATE LOGURU_DEBUG_LOGGING)
# Build lithium_server executable
add_executable(lithium_server ${lithium_src_dir}/App.cpp)

target_link_libraries(lithium_server OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(lithium_server ${ZLIB_LIBRARIES})
target_link_libraries(lithium_server sqlite3)
target_link_libraries(lithium_server cpp_httplib)
target_link_libraries(lithium_server backward)
target_link_libraries(lithium_server tinyxml2)
target_link_libraries(lithium_server pocketpy)
target_link_libraries(lithium_server
PRIVATE
lithium_server-library
lithium_webserver
lithium-config
lithium-task
oatpp-websocket
oatpp-swagger
oatpp-openssl
oatpp-zlib
oatpp
loguru
libzippp
atomstatic
carbon
fmt::fmt
OpenSSL::SSL
OpenSSL::Crypto
${ZLIB_LIBRARIES}
sqlite3
cpp_httplib
backward
tinyxml2
pocketpy
)

if(WIN32)
target_link_libraries(lithium_server pdh iphlpapi winmm crypt32 wsock32 ws2_32)
find_package(dlfcn-win32 REQUIRED)
target_link_libraries(lithium_server dlfcn-win32::dl)
target_link_libraries(lithium_server
PRIVATE
pdh
iphlpapi
winmm
crypt32
wsock32
ws2_32
dlfcn-win32::dl
)
elseif(UNIX OR LINUX OR APPLE)
target_link_libraries(lithium_server dl)
target_link_libraries(lithium_server PRIVATE dl)
else()
message(FATAL_ERROR "Unsupported platform")
endif()

target_compile_definitions(lithium_server PRIVATE LOGURU_DEBUG_LOGGING)

# Set output name for Lithium executable
set_target_properties(
lithium_server
PROPERTIES
OUTPUT_NAME lithium_server
)
set_target_properties(lithium_server PROPERTIES OUTPUT_NAME lithium_server)

# Set install paths
if(UNIX AND NOT APPLE)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX /usr CACHE PATH "Lithium install path" FORCE)
endif()
endif()

if(WIN32)
set(CMAKE_INSTALL_PREFIX "C:/Program Files/LithiumServer")
elseif(LINUX)
set(CMAKE_INSTALL_PREFIX "/usr/lithium")
endif()

# Enable folder grouping in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
Loading
Loading