Skip to content
Open
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
59 changes: 48 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 3.23)
project(soar
VERSION 9.6.3
LANGUAGES CXX)
LANGUAGES CXX C)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is C used for? I thought it was used in the viewer but not in the rest of SVS, but the viewer is going away. Or is it in a dependency?


set(SOAR_LIB "${PROJECT_NAME}_lib")

find_package(SQLite3 REQUIRED)

Expand Down Expand Up @@ -61,14 +63,35 @@ file(GLOB_RECURSE HEADERS
"Core/shared/portability_posix.h"
)

if(NOT SVS)
# Add additional files/dependencies if SVS is enabled
if(SVS)
message(STATUS "Soar: Enabling SVS")
find_package(asio REQUIRED)
find_package(Eigen3 REQUIRED)

# Build ccd as a static library (conan's libccd does not work for our needs)
add_subdirectory(Core/SVS/ccd)

list(APPEND SOURCES
Core/SVS/SVS_cmake.cxx
)

file(GLOB_RECURSE SVS_HEADERS
"Core/SVS/src/*.h"
"Core/SVS/src/commands/*.h"
"Core/SVS/src/filters/*.h"
)
list(APPEND HEADERS ${SVS_HEADERS})
else()
message(STATUS "Soar: Disabling SVS")
add_compile_definitions(NO_SVS)
endif()



# Add executable/library target
add_library(${PROJECT_NAME}_lib ${SOURCES})
target_include_directories(${PROJECT_NAME}_lib PUBLIC
add_library(${SOAR_LIB} ${SOURCES})
target_include_directories(${SOAR_LIB} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Core/CLI/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Core/ClientSML/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Core/ConnectionSML/src>
Expand All @@ -90,23 +113,37 @@ target_include_directories(${PROJECT_NAME}_lib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Core/shared>
$<INSTALL_INTERFACE:include/soar>
)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC SQLite::SQLite3)
target_link_libraries(${SOAR_LIB} PUBLIC SQLite::SQLite3)

if(SVS)
target_include_directories(${SOAR_LIB} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Core/SVS/ccd>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Core/SVS/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Core/SVS/src/filters>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Core/SVS/src/commands>
)

target_link_libraries(${SOAR_LIB} PUBLIC asio::asio)
target_link_libraries(${SOAR_LIB} PUBLIC Eigen3::Eigen)
target_link_libraries(${SOAR_LIB} PUBLIC ccd)
endif()


set_target_properties(${PROJECT_NAME}_lib
set_target_properties(${SOAR_LIB}
PROPERTIES
PUBLIC_HEADER "${HEADERS}")

set(CXX_STANDARD_REQUIRED True)

# Set the C++ standard for this and all downstream targets
target_compile_features(${PROJECT_NAME}_lib PUBLIC
target_compile_features(${SOAR_LIB} PUBLIC
cxx_std_17
)

if($<CONFIG:DEBUG>)
target_compile_options(${PROJECT_NAME}_lib PRIVATE $<$<CXX_COMPILER_ID:Clang,AppleClang,GNU>: -Wall -Wpedantic>)
target_compile_options(${SOAR_LIB} PRIVATE $<$<CXX_COMPILER_ID:Clang,AppleClang,GNU>: -Wall -Wpedantic>)

target_compile_options(${PROJECT_NAME}_lib PRIVATE $<$<CXX_COMPILER_ID:MSVC>: /Wall /permissive>)
target_compile_options(${SOAR_LIB} PRIVATE $<$<CXX_COMPILER_ID:MSVC>: /Wall /permissive>)

if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if(ASAN)
Expand Down Expand Up @@ -135,7 +172,7 @@ write_basic_package_version_file(
COMPATIBILITY SameMajorVersion)

# This only sets up the install structure, but no installation happens yet.
install(TARGETS ${PROJECT_NAME}_lib
install(TARGETS ${SOAR_LIB}
EXPORT SoarTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down Expand Up @@ -170,7 +207,7 @@ export(EXPORT SoarTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/SoarTargets.cmake"
)

add_library(soar::soar_lib ALIAS ${PROJECT_NAME}_lib)
add_library(soar::soar_lib ALIAS ${SOAR_LIB})

if(CLI)
message(STATUS "Soar: Building CLI")
Expand Down
34 changes: 34 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@
"SVS": "OFF",
"CLI": "ON"
}
},
{
"name": "Release-svs-test",
"displayName": "Release with SVS Test Configuration",
"inherits": "conan-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_TESTS": "ON",
"ASAN": "OFF",
"SVS": "ON",
"CLI": "ON"
}
}
],
"buildPresets": [
Expand Down Expand Up @@ -85,6 +97,13 @@
"configurePreset": "Release-test",
"configuration": "release",
"inherits": "conan-release"
},
{
"name": "Release-svs-test",
"displayName": "Build Release with SVS Test",
"configurePreset": "Release-svs-test",
"configuration": "release",
"inherits": "conan-release"
}
],
"testPresets": [
Expand Down Expand Up @@ -113,6 +132,14 @@
"output": {
"outputOnFailure": true
}
},
{
"name": "Release-svs-test",
"displayName": "Test Release with SVS",
"configurePreset": "Release-svs-test",
"output": {
"outputOnFailure": true
}
}
],
"packagePresets": [
Expand All @@ -122,6 +149,13 @@
"configurePreset": "Release-test",
"generators": ["TGZ"],
"packageDirectory": "${sourceDir}/"
},
{
"name": "Release-svs-test",
"displayName": "Package Release with SVS Test",
"configurePreset": "Release-svs-test",
"generators": ["TGZ"],
"packageDirectory": "${sourceDir}/"
}
],
"workflowPresets": [
Expand Down
69 changes: 0 additions & 69 deletions Core/SVS/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,6 @@ import sys, platform

Import('env', 'compiler', 'lsb_build')

# svs viewer
viewer_env = env.Clone()
viewer_env['LIBS'] = []
viewer_env['CPPPATH'] = [ 'viewer', 'glfw/lib' ]
viewer_env.Append(CPPPATH = 'glfw/include')
viewer_src = Glob('viewer/*.c') + Glob('glfw/lib/*.c')

if compiler == 'msvc':
opengl_libs = [ 'opengl32', 'glu32' ]
viewer_env.Append(
CPPPATH = [ 'glfw/lib/win32' ],
LIBS = [ 'Ws2_32', 'Mswsock', 'AdvApi32', 'user32' ] + opengl_libs,
LINKFLAGS = [ '/SUBSYSTEM:CONSOLE' ]
)
viewer_src.append('viewer/platform_specific/windows.c')
viewer_src.extend(Glob('glfw/lib/win32/*.c'))
else:
viewer_src.append('viewer/platform_specific/posix.c')
if sys.platform == 'darwin':
viewer_src.extend(Glob('glfw/lib/cocoa/*.c') + Glob('glfw/lib/cocoa/*.m'))
opengl_libs = [] # osx uses opengl as a framework instead of libraries
viewer_env.Append(
CPPFLAGS = [ '-fno-common' ],
CPPPATH = [ 'glfw/lib/cocoa/' ],
)
for f in [ 'Cocoa', 'OpenGL', 'IOKit' ]:
viewer_env.Append(LINKFLAGS = [ '-framework', f ])
else:
viewer_src.extend(Glob('glfw/lib/x11/*.c'))
opengl_libs = [ 'GL', 'GLU' ]
viewer_env.Append(
CPPFLAGS = [
'-pthread',
'-D_GLFW_HAS_PTHREAD',
'-D_GLFW_HAS_SYSCONF',
'-D_GLFW_HAS_SCHED_YIELD',
],
CPPPATH = [ 'glfw/lib/x11' ],
LIBS = [ 'm', 'pthread', 'X11', 'rt' ] + opengl_libs,
)

conf = Configure(viewer_env)
missing_libs = [ l for l in opengl_libs if not conf.CheckLib(l) ]

if platform.system().startswith('Linux'):
PROCADDRESS_FUNCS = [
('glXGetProcAddressARB', 'GLXGETPROCADDRESSARB'),
('glXGetProcAddress', 'GLXGETPROCADDRESS'),
('glXGetProcAddressEXT', 'GLXGETPROCADDRESSEXT'),
]
macro = '_GLFW_HAS_DLOPEN' # fallback
for f, m in PROCADDRESS_FUNCS:
if conf.CheckLibWithHeader('GL', 'GL/gl.h', 'C', '%s("");' % f):
macro = m
break;
viewer_env.Append(CPPFLAGS='-D_GLFW_HAS_' + macro)
elif platform.system() == 'Darwin':
viewer_env.Append(CPPFLAGS='-D_GLFW_HAS_GLXGETPROCADDRESS')

conf.Finish()

if not platform.system() == 'Darwin':
if not missing_libs:
viewer_prog = viewer_env.Program('svs_viewer', viewer_src)
viewer_install = viewer_env.Alias('svs_viewer', viewer_env.Install('$OUT_DIR', viewer_prog))
else:
print('Cannot find %s, not building svs_viewer' % ', '.join(missing_libs))
else:
print('Not building svs_viewer for OSX')

# svs library objects
svs_env = env.Clone()
Expand Down
38 changes: 38 additions & 0 deletions Core/SVS/SVS_cmake.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "src/commands/add_node.cpp"
#include "src/commands/extract.cpp"
#include "src/commands/set_transform.cpp"
#include "src/commands/set_tag.cpp"
#include "src/commands/delete_tag.cpp"
#include "src/commands/copy_node.cpp"
#include "src/commands/copy_transform.cpp"
#include "src/commands/delete_node.cpp"

#include "src/filters/axis_distance.cpp"
#include "src/filters/axis_relation.cpp"
#include "src/filters/base_node_filters.cpp"
#include "src/filters/calculate_placement.cpp"
#include "src/filters/contain.cpp"
#include "src/filters/distance.cpp"
#include "src/filters/intersect.cpp"
#include "src/filters/monitor_object.cpp"
#include "src/filters/node.cpp"
#include "src/filters/occlusion.cpp"
#include "src/filters/overlap.cpp"
#include "src/filters/tag_select.cpp"
#include "src/filters/volume.cpp"

#include "src/cliproxy.cpp"
#include "src/command.cpp"
#include "src/command_table.cpp"
#include "src/common.cpp"
#include "src/drawer_asio.cpp"
#include "src/filter.cpp"
#include "src/filter_input.cpp"
#include "src/filter_table.cpp"
#include "src/mat.cpp"
#include "src/scene.cpp"
#include "src/serialize.cpp"
#include "src/sgnode.cpp"
#include "src/sgnode_algs.cpp"
#include "src/soar_interface.cpp"
#include "src/svs.cpp"
33 changes: 33 additions & 0 deletions Core/SVS/ccd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ccd/CMakeLists.txt

set(CCD_SRC
ccd.c
mpr.c
polytope.c
support.c
vec3.c
)

# Create a static library named ccd
add_library(ccd STATIC ${CCD_SRC})

# Include the current directory as a public include path
target_include_directories(ccd PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)

# Set C standard explicitly
target_compile_features(ccd PUBLIC c_std_99)

set_target_properties(ccd PROPERTIES LINKER_LANGUAGE C)

# Installation Structure
install(TARGETS ccd
EXPORT SoarTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)


Loading
Loading