Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ StyleCopReport.xml
*.ilk
*.meta
*.obj
# Exception: track 3D mesh files in resources
!resources/**/*.obj
*.idb
*.iobj
*.pch
Expand Down
23 changes: 15 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ cmake_minimum_required(VERSION 3.16)
project(circus VERSION 0.1.0 LANGUAGES CXX)
add_compile_definitions(_LIBCPP_DISABLE_AVAILABILITY)

set(LIBRARY ${PROJECT_NAME})
set(EXECUTABLE ${PROJECT_NAME}-main)
set(LIBRARY ${PROJECT_NAME}-lib)
set(EXECUTABLE ${PROJECT_NAME})
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/.clangd"
"CompileFlags:\n CompilationDatabase: ${CMAKE_CURRENT_BINARY_DIR}\n")
add_compile_definitions(PROJECT_ROOT="${CMAKE_SOURCE_DIR}")
include(FetchContent)

Expand All @@ -36,6 +34,11 @@ find_package(Qt6 REQUIRED COMPONENTS Core Widgets OpenGLWidgets)
find_package(nlohmann_json QUIET)
find_package(CURL QUIET)

# Generate .clangd configuration after dependencies are found
get_target_property(EIGEN_INCLUDE_DIR Eigen3::Eigen INTERFACE_INCLUDE_DIRECTORIES)
file(WRITE "${CMAKE_CURRENT_SOURCE_DIR}/.clangd"
"CompileFlags:\n CompilationDatabase: ${CMAKE_CURRENT_BINARY_DIR}\n Add:\n - -I${CMAKE_CURRENT_SOURCE_DIR}/include\n - -isystem${EIGEN_INCLUDE_DIR}\n")

# -------------------- yaml-cpp (config -> module -> manual) [robust]
set(_YAML_HINT "/opt/homebrew/opt/yaml-cpp")
find_package(yaml-cpp CONFIG QUIET)
Expand Down Expand Up @@ -119,8 +122,8 @@ endif()
# ======================= CIRCUS LIBRARY ============================================================

# -------------------- Collect sources and split into: core, main, bindings
set(_src_dir "${CMAKE_SOURCE_DIR}/Src")
set(_include_dir "${CMAKE_SOURCE_DIR}/Include")
set(_src_dir "${CMAKE_SOURCE_DIR}/src")
set(_include_dir "${CMAKE_SOURCE_DIR}/include")

# Source files
file(GLOB_RECURSE SOURCES ${_src_dir}/*.cpp)
Expand Down Expand Up @@ -201,16 +204,20 @@ include(CMakePackageConfigHelpers)
include(GNUInstallDirs)

# 1. Install the library target and headers
set_target_properties(${LIBRARY} PROPERTIES PUBLIC_HEADER "${HEADERS}")
install(TARGETS ${LIBRARY}
EXPORT ${LIBRARY}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)

# Install headers preserving directory structure
install(DIRECTORY ${_include_dir}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)

# 2. Generate the relocatable package config file in the build directory
configure_package_config_file( # creates config file for find_package
"cmake/config.cmake.in"
Expand Down
Loading