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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ tags
/test/notsosimplevector
/test/shapes
/test/trie
/test/unicode-test
/test/unicode-test
209 changes: 209 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
cmake_minimum_required(VERSION 3.10)
project(dillo VERSION 3.3.0 LANGUAGES C CXX)

# CMake policy settings
cmake_policy(SET CMP0072 NEW) # OpenGL preference
cmake_policy(SET CMP0009 NEW) # FILE GLOB_RECURSE behavior

# Include GNUInstallDirs for standard installation directories
include(GNUInstallDirs)

# Set output directories to build directory root
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

# Multi-config generators support
foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${CONFIG} CONFIG_UPPER)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONFIG_UPPER} ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONFIG_UPPER} ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_UPPER} ${CMAKE_BINARY_DIR})
endforeach()

# Set C and C++ standards
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Configuration options
option(ENABLE_COOKIES "Enable cookies support" ON)
option(ENABLE_PNG "Enable PNG images support" ON)
option(ENABLE_WEBP "Enable WebP images support" ON)
option(ENABLE_JPEG "Enable JPEG images support" ON)
option(ENABLE_GIF "Enable GIF images support" ON)
option(ENABLE_SVG "Enable SVG images support" ON)
option(ENABLE_IPV6 "Enable IPv6 support" ON)
option(ENABLE_TLS "Enable TLS support" ON)
option(ENABLE_XEMBED "Enable X11 XEmbed support" ON)
option(ENABLE_CONTROL_SOCKET "Enable control socket" ON)

# Find required packages
find_package(PkgConfig)

# Find FLTK
find_package(FLTK REQUIRED)

# Find X11
find_package(X11 REQUIRED)

# Find threading
find_package(Threads REQUIRED)

# Find iconv
find_path(ICONV_INCLUDE_DIR iconv.h)
find_library(ICONV_LIBRARY iconv)
if(ICONV_INCLUDE_DIR AND ICONV_LIBRARY)
set(ICONV_FOUND TRUE)
else()
set(ICONV_FOUND FALSE)
endif()

# Find zlib
find_package(ZLIB)

# Find OpenSSL for TLS support
if(ENABLE_TLS)
find_package(OpenSSL)
if(OPENSSL_FOUND)
set(HAVE_OPENSSL TRUE)
add_definitions(-DHAVE_OPENSSL)
endif()
endif()

# Find libpng
if(ENABLE_PNG)
find_package(PNG)
if(PNG_FOUND)
add_definitions(-DENABLE_PNG)
endif()
endif()

# Find libjpeg
if(ENABLE_JPEG)
find_package(JPEG)
if(JPEG_FOUND)
add_definitions(-DENABLE_JPEG)
endif()
endif()

# Find libwebp
if(ENABLE_WEBP)
pkg_check_modules(WEBP libwebp)
if(WEBP_FOUND)
add_definitions(-DENABLE_WEBP)
endif()
endif()

# Compiler flags
# Suppress unused parameter warnings - many function parameters are required for API compatibility
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter")

# Debug flags for Debug builds
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
endif()

# Release flags for Release builds
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -DNDEBUG")
endif()

# Add FLTK flags
add_compile_options(${FLTK_CXXFLAGS})

# Configuration definitions
add_definitions(-DDILLO_SYSCONF="${CMAKE_INSTALL_FULL_SYSCONFDIR}/dillo/")
add_definitions(-DDILLO_DOCDIR="${CMAKE_INSTALL_FULL_DOCDIR}/")
add_definitions(-DDILLO_LIBDIR="${CMAKE_INSTALL_FULL_LIBDIR}/dillo/")

# System paths for dpid
add_definitions(-DDPIDRC_SYS="${CMAKE_INSTALL_SYSCONFDIR}/dpidrc")


# Enable features based on options
if(ENABLE_COOKIES)
add_definitions(-DENABLE_COOKIES)
endif()

if(ENABLE_GIF)
add_definitions(-DENABLE_GIF)
endif()

if(ENABLE_SVG)
add_definitions(-DENABLE_SVG)
endif()

if(ENABLE_IPV6)
add_definitions(-DENABLE_IPV6)
endif()

if(ENABLE_XEMBED)
add_definitions(-DENABLE_XEMBED)
endif()

# Include directories
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${ICONV_INCLUDE_DIR})

# Subdirectories
add_subdirectory(lout)
add_subdirectory(dw)
add_subdirectory(dlib)
add_subdirectory(dpip)
add_subdirectory(src/IO)
add_subdirectory(dpid)
add_subdirectory(dpi)
add_subdirectory(src)


# Installation configuration
install(FILES dillorc DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/dillo)
install(FILES dillo.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)

# Install icons if they exist
if(EXISTS "${CMAKE_SOURCE_DIR}/icons/48x48/dillo.png")
install(FILES icons/48x48/dillo.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps/)
endif()
if(EXISTS "${CMAKE_SOURCE_DIR}/icons/128x128/dillo.png")
install(FILES icons/128x128/dillo.png
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps/)
endif()

# Install scripts
install(PROGRAMS dillo-install-hyphenation DESTINATION ${CMAKE_INSTALL_BINDIR})

# Add uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)

add_custom_target(uninstall
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
COMMENT "Uninstalling Dillo..."
)
endif()

# Print configuration summary
message(STATUS "Dillo Configuration Summary:")
message(STATUS " Version: ${PROJECT_VERSION}")
message(STATUS " Install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS " Cookies: ${ENABLE_COOKIES}")
message(STATUS " PNG: ${ENABLE_PNG}")
message(STATUS " JPEG: ${ENABLE_JPEG}")
message(STATUS " GIF: ${ENABLE_GIF}")
message(STATUS " SVG: ${ENABLE_SVG}")
message(STATUS " WebP: ${ENABLE_WEBP}")
message(STATUS " IPv6: ${ENABLE_IPV6}")
message(STATUS " TLS: ${ENABLE_TLS}")
message(STATUS " XEmbed: ${ENABLE_XEMBED}")
message(STATUS " Control Socket: ${ENABLE_CONTROL_SOCKET}")
137 changes: 137 additions & 0 deletions README.CMake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Dillo CMake Build System

This directory contains a modern CMake build system for the Dillo web browser, replacing the traditional autotools-based build process.

## Quick Start

### Prerequisites
- CMake 3.10 or higher
- C++11 compatible compiler
- FLTK development libraries
- OpenSSL (for TLS support)
- libpng, libjpeg (for image support)
- pkg-config

### Build
```bash
# Configure and build
cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel 4

# Install (requires sudo for system installation)
sudo cmake --install build

# Run from build directory (development)
./build/dillo
```

### Uninstall
```bash
sudo cmake --build build --target uninstall
```

## Build Options

All features can be enabled/disabled with CMake options:

```bash
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_COOKIES=ON \
-DENABLE_PNG=ON \
-DENABLE_JPEG=ON \
-DENABLE_GIF=ON \
-DENABLE_SVG=ON \
-DENABLE_WEBP=ON \
-DENABLE_IPV6=ON \
-DENABLE_TLS=ON \
-DENABLE_XEMBED=ON \
-DENABLE_CONTROL_SOCKET=ON
```

## Installation Paths

By default, files are installed to standard locations:
- Executables: `/usr/local/bin/`
- Configuration: `/usr/local/etc/dillo/`
- DPI plugins: `/usr/local/lib/dillo/dpi/`
- Desktop files: `/usr/local/share/applications/`
- Icons: `/usr/local/share/icons/hicolor/`

To change the installation prefix:
```bash
cmake -B build -DCMAKE_INSTALL_PREFIX=/usr
```

## Development

### Running from Build Directory
After building, you can run dillo directly from the build directory:

```bash
./build/dillo
```

Note: For full functionality (DPI plugins, configuration files), you should install the package first with `sudo cmake --install build`.

### Build Targets
- `dillo` - Main browser executable
- `dpid_bin` - DPI daemon (installed as `dpid`)
- `dpidc` - DPI client
- `dilloc` - Control socket client
- Various `.dpi` plugins for different protocols

### Output Directory
All executables are built to the build directory root for easy access during development.

## Migration from Autotools

This CMake build system is a drop-in replacement for the autotools build system. Key differences:

1. **Build commands**: Use `cmake` instead of `./configure && make`
2. **Configuration**: CMake options instead of configure flags
3. **Modern build system**: Better dependency management and cross-platform support
4. **Clean output**: All executables built to build directory root

## Troubleshooting

### Common Issues

**"cannot open output file .: Is a directory"**
- This was a target name conflict that has been resolved
- The `dpid` target is now built as `dpid_bin` to avoid directory conflicts

**Missing dependencies**
- Install FLTK development packages: `libfltk1.3-dev`
- Install image libraries: `libpng-dev libjpeg-dev`
- Install OpenSSL: `libssl-dev`

### Clean Build
To start fresh:
```bash
rm -rf build/
cmake -B build -DCMAKE_BUILD_TYPE=Debug
cmake --build build --parallel 4
```

## Architecture

The build system is organized as follows:
- `CMakeLists.txt` - Main configuration and options
- `lout/CMakeLists.txt` - Utility library
- `dw/CMakeLists.txt` - Display widget libraries (3 sub-libraries)
- `dlib/CMakeLists.txt` - Dillo utility library
- `dpip/CMakeLists.txt` - DPI interface library
- `src/IO/CMakeLists.txt` - Input/output library with TLS support
- `src/CMakeLists.txt` - Main browser and control client
- `dpid/CMakeLists.txt` - DPI daemon and client
- `dpi/CMakeLists.txt` - All DPI plugins

## Contributing

When modifying the build system:
1. Test both Debug and Release builds
2. Verify installation and uninstallation work
3. Test running from build directory
4. Ensure all targets build without warnings
5. Update this documentation for any new features
44 changes: 44 additions & 0 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# CMake uninstall script for Dillo

if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif()

file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")

foreach(file ${files})
message(STATUS "Removing: ${file}")
if(EXISTS "${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "${file}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE error
)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Failed to remove ${file}: ${error}")
endif()
else()
message(STATUS "File does not exist: ${file}")
endif()
endforeach()

# Remove empty directories
file(GLOB_RECURSE dirs "@CMAKE_INSTALL_PREFIX@/*")
list(REVERSE dirs)

foreach(dir ${dirs})
if(IS_DIRECTORY "${dir}")
file(GLOB dir_contents "${dir}/*")
if(dir_contents STREQUAL "")
message(STATUS "Removing empty directory: ${dir}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove_directory "${dir}"
RESULT_VARIABLE result
)
endif()
endif()
endforeach()

message(STATUS "Uninstall completed successfully!")
Loading
Loading