Skip to content

compiling in 20 minutes instead of 4 hours, making webots more packageable and easy to compile #6832

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

Draft
wants to merge 12 commits into
base: develop
Choose a base branch
from
Draft
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
150 changes: 76 additions & 74 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,74 +1,76 @@
# Global rules #
################

# Build directories
build
com
webots_catkin_ws

# Compiled source
*.exe
*.o
*.d
*.class
*.so
*.dylib
*.dll
*.lib
*.a
*.cof
*.hex
*.pyc
*.gch

# Packages
*.7z
*.bz2
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.xz
*.zip

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
.directory
ehthumbs.db
Thumbs.db
*.swp

# Text editor backup files
*~

# Log files
*.log

# Blender cache
*.blend1

# Webots generated files
*.cache

# IDE files
.vscode

# Local rules #
###############

/.clang-format
/msys64
/webots
/webots-controller
/webots.lnk
/webots_debug_output.txt
/util

# world thumbnail files
.*.jpg
# Global rules #
################

# Build directories
build
com
webots_catkin_ws

# Compiled source
*.exe
*.o
*.d
*.class
*.so
*.dylib
*.dll
*.lib
*.a
*.cof
*.hex
*.pyc
*.gch

# Packages
*.7z
*.bz2
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.xz
*.zip

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
.directory
ehthumbs.db
Thumbs.db
*.swp

# Text editor backup files
*~

# Log files
*.log

# Blender cache
*.blend1

# Webots generated files
*.cache

# IDE files
.vscode

# Local rules #
###############

/.clang-format
/msys64
/webots
/webots-controller
/webots.lnk
/webots_debug_output.txt
/util

# world thumbnail files
.*.jpg
.aider*
.env
89 changes: 89 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
cmake_minimum_required(VERSION 3.10)
project(webots)

# Handle dynamic loading library
if(WIN32)
find_package(dlfcn-win32 REQUIRED)
set(CMAKE_DL_LIBS dlfcn-win32::dl)
else()
set(CMAKE_DL_LIBS ${CMAKE_DL_LIBS})
endif()

# Installation configuration
if(NOT CMAKE_INSTALL_PREFIX)
# Check if we can write to /usr/local
execute_process(COMMAND test -w /usr/local RESULT_VARIABLE can_write_usr_local)
if(can_write_usr_local EQUAL 0)
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation prefix" FORCE)
else()
# Fallback to ~/.local
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/.local" CACHE PATH "Installation prefix" FORCE)
endif()
endif()

message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Find Qt6 components
find_package(Qt6 REQUIRED COMPONENTS
Core
Gui
OpenGL
Qml
QmlIntegration
PrintSupport
Widgets
Xml
OpenGLWidgets
WebSockets
Test
Network
)
file(READ ${CMAKE_SOURCE_DIR}/resources/version.txt WEBOTS_VERSION) # Path is correct - ${CMAKE_SOURCE_DIR} handles OS-specific path separators
string(STRIP ${WEBOTS_VERSION} WEBOTS_VERSION)
# Find other required packages
find_package(OpenAL REQUIRED)
find_package(OpenGL REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(Freetype REQUIRED)
find_package(assimp REQUIRED)
pkg_check_modules(OPENVR REQUIRED IMPORTED_TARGET openvr)
# Include external dependencies
include(src/webots/cmake/ExternalDependencies.cmake)

# Add subdirectories
# Installation rules
install(DIRECTORY resources/
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/webots/resources
PATTERN ".gitkeep" EXCLUDE
PATTERN "*.user" EXCLUDE
PATTERN "*.lock" EXCLUDE
)

install(DIRECTORY projects/
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/webots/projects
PATTERN ".gitkeep" EXCLUDE
PATTERN "*.user" EXCLUDE
PATTERN "*.lock" EXCLUDE
)

# Add subdirectories
add_subdirectory(src)

# Install main executable
install(TARGETS webots
RUNTIME DESTINATION bin
BUNDLE DESTINATION .
)

# Install libraries
install(TARGETS Controller CppController
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
28 changes: 28 additions & 0 deletions projects/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# CMakeLists.txt for the 'projects' directory
# This file is part of the effort to port the Webots build system from Make to CMake.

cmake_minimum_required(VERSION 3.10)

# Assuming CMAKE_SOURCE_DIR points to the root of the Webots project.
# This variable can be used by sub-projects if they need to reference the Webots root.
set(WEBOTS_HOME ${CMAKE_SOURCE_DIR} CACHE INTERNAL "Path to Webots root directory")

message(STATUS "Configuring Webots Projects from: ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "WEBOTS_HOME for projects set to: ${WEBOTS_HOME}")

# Add subdirectories. Each of these will require its own CMakeLists.txt
# to define how its contents are built and installed.
add_subdirectory(languages)
add_subdirectory(default)
add_subdirectory(objects)
add_subdirectory(robots)
add_subdirectory(samples)
add_subdirectory(vehicles)
add_subdirectory(humans)

# Install guided_tour.txt to the correct projects directory in the install location
install(FILES guided_tour.txt DESTINATION share/webots/projects)

# The Makefile targets (release, profile, debug, clean, cleanse)
# are generally handled by CMake's built-in build type configurations (CMAKE_BUILD_TYPE)
# and the standard 'clean' target generated by CMake.
9 changes: 9 additions & 0 deletions projects/default/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Placeholder CMakeLists.txt for projects/default
# TODO: Convert the logic from projects/default/Makefile to CMake.

cmake_minimum_required(VERSION 3.10)
project(webots_project_default)

message(STATUS "Configuring projects/default")

# Add build targets, sources, and installation rules here.
9 changes: 9 additions & 0 deletions projects/humans/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Placeholder CMakeLists.txt for projects/humans
# TODO: Convert the logic from projects/humans/Makefile to CMake.

cmake_minimum_required(VERSION 3.10)
project(webots_project_humans)

message(STATUS "Configuring projects/humans")

# Add build targets, sources, and installation rules here.
13 changes: 13 additions & 0 deletions projects/languages/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Placeholder CMakeLists.txt for projects/languages
# TODO: Convert the logic from projects/languages/Makefile to CMake.

cmake_minimum_required(VERSION 3.10)
project(webots_project_languages)

message(STATUS "Configuring projects/languages")

# Add build targets, sources, and installation rules here.
# For example:
# add_library(my_language_library my_source.c)
# target_link_libraries(my_language_library PRIVATE ${WEBOTS_HOME}/lib/Controller.so) # Example dependency
# install(TARGETS my_language_library DESTINATION lib)
9 changes: 9 additions & 0 deletions projects/objects/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Placeholder CMakeLists.txt for projects/objects
# TODO: Convert the logic from projects/objects/Makefile to CMake.

cmake_minimum_required(VERSION 3.10)
project(webots_project_objects)

message(STATUS "Configuring projects/objects")

# Add build targets, sources, and installation rules here.
9 changes: 9 additions & 0 deletions projects/robots/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Placeholder CMakeLists.txt for projects/robots
# TODO: Convert the logic from projects/robots/Makefile to CMake.

cmake_minimum_required(VERSION 3.10)
project(webots_project_robots)

message(STATUS "Configuring projects/robots")

# Add build targets, sources, and installation rules here.
9 changes: 9 additions & 0 deletions projects/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Placeholder CMakeLists.txt for projects/samples
# TODO: Convert the logic from projects/samples/Makefile to CMake.

cmake_minimum_required(VERSION 3.10)
project(webots_project_samples)

message(STATUS "Configuring projects/samples")

# Add build targets, sources, and installation rules here.
9 changes: 9 additions & 0 deletions projects/vehicles/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Placeholder CMakeLists.txt for projects/vehicles
# TODO: Convert the logic from projects/vehicles/Makefile to CMake.

cmake_minimum_required(VERSION 3.10)
project(webots_project_vehicles)

message(STATUS "Configuring projects/vehicles")

# Add build targets, sources, and installation rules here.
25 changes: 25 additions & 0 deletions resources/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# CMakeLists.txt for the 'resources' directory
# This file is part of the effort to port the Webots build system from Make to CMake.

cmake_minimum_required(VERSION 3.10)

message(STATUS "Configuring Webots Resources from: ${CMAKE_CURRENT_SOURCE_DIR}")

# Add subdirectories. Each of these will require its own CMakeLists.txt
# to define how its contents are built/processed and installed.
add_subdirectory(translations)
add_subdirectory(projects) # This is resources/projects

# Other files and directories in 'resources' (like fonts, icons, images, templates, etc.)
# are typically handled by 'install(DIRECTORY ...)' commands in the root CMakeLists.txt
# or directly here if specific processing is needed before installation.
# The existing root CMakeLists.txt already has:
# install(DIRECTORY resources/ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/webots/resources ...)
# This will cover most static assets. If specific files from 'resources' need to be
# generated or processed by CMake, that logic would go here or in specific subdirectory CMakeLists.txt files.

# The Makefile targets (release, debug, profile, clean, cleanse)
# are generally handled by CMake's built-in build type configurations (CMAKE_BUILD_TYPE)
# and the standard 'clean' target generated by CMake.
# Specific cleaning tasks like 'rm -rf sumo_exporter/*.pyc' would need
# to be translated into custom clean commands or handled by the build process of 'sumo_exporter' if it gets its own CMakeLists.txt.
17 changes: 17 additions & 0 deletions resources/projects/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Placeholder CMakeLists.txt for resources/projects
# TODO: Convert the logic from resources/projects/Makefile to CMake.
# This will involve adding subdirectories for controllers, libraries, plugins, worlds.

cmake_minimum_required(VERSION 3.10)
project(webots_resources_projects)

message(STATUS "Configuring resources/projects")

# Add subdirectories. Each of these will require its own CMakeLists.txt.
add_subdirectory(controllers)
add_subdirectory(libraries)
add_subdirectory(plugins)
add_subdirectory(worlds)

# Add build targets, sources, and installation rules here as needed
# for any direct content of resources/projects, if any.
Loading