This project supports building with CMake as a modern alternative to the traditional Autotools build system.
- CMake >= 3.15
- C compiler (GCC, Clang, MSVC, or MinGW)
- libartnet >= 1.1.0 - ArtNet protocol library
- Git (for cloning libartnet if building from source)
- (Optional) ncurses library - for building artnet_dmxconsole and artnet_dmxmonitor
- Build tools:
build-essential,cmake - libartnet development package or source
- (Optional)
libncurses-devfor console programs
- Xcode Command Line Tools or GCC
- CMake (via Homebrew:
brew install cmake) - libartnet (via Homebrew or build from source)
- (Optional) ncurses (usually pre-installed)
MSYS2 Environment (Recommended)
- MSYS2 from https://www.msys2.org/
- MinGW64 toolchain and CMake
- libartnet built in MSYS2 environment
By default, CMake will automatically download and build libartnet from GitHub if it's not found on your system. This requires:
- Git installed and accessible
- Internet connection
- On Windows: MSYS2/MinGW environment with autotools
Ubuntu/Debian:
sudo apt-get install libartnet-devFedora/RHEL:
sudo dnf install libartnet-develmacOS (Homebrew):
brew install libartnetLinux/macOS:
git clone https://github.com/OpenLightingProject/libartnet.git
cd libartnet
./autogen.sh
./configure --prefix=/usr/local
make
sudo make installWindows (MSYS2 MINGW64):
git clone https://github.com/OpenLightingProject/libartnet.git
cd libartnet
./autogen.sh
./configure --prefix=/mingw64
make
make install# Navigate to project directory
cd artnet-examples
# Create build directory
mkdir build
cd build
# Configure project
cmake ..
# Build
cmake --build .
# Install (optional)
sudo cmake --install .# Open MSYS2 MINGW64 terminal
cd /d/work_space/opensource_project/artnet-examples
# Create build directory
mkdir build
cd build
# Configure with Ninja generator
cmake .. -G "Ninja"
# Build
ninja
# Or use standard make-based build
cmake --build .# Open PowerShell or CMD
cd D:\work_space\opensource_project\artnet-examples
# Create build directory
mkdir build
cd build
# Configure for Visual Studio
cmake .. -G "Visual Studio 17 2022" -A x64
# Build
cmake --build . --config Release
# Or open the generated .sln file in Visual StudioControl whether to build programs that require ncurses (artnet_dmxconsole and artnet_dmxmonitor).
# Disable ncurses programs
cmake .. -DBUILD_NCURSES_PROGS=OFFDefault: ON (enabled)
If CMake cannot automatically find libartnet, you can specify its location:
cmake .. \
-DLIBARTNET_INCLUDE_DIRS="/path/to/libartnet/include" \
-DLIBARTNET_LIBRARIES="/path/to/libartnet/lib/libartnet.a"# Debug build (with debug symbols)
cmake .. -DCMAKE_BUILD_TYPE=Debug
# Release build (optimized)
cmake .. -DCMAKE_BUILD_TYPE=Release
# Release with debug info
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo# Install to custom location
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/.local
# System-wide installation (default: /usr/local)
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/localAfter successful compilation, executables will be located in the build/src/ directory:
artnet_discover- Discover ArtNet nodes on the networkartnet_setdmx- Set DMX channel valuesartnet_flood_rx- ArtNet flood receiver for testingartnet_flood_tx- ArtNet flood transmitter for testingartnet_profile_rx- Performance profiling receiverartnet_profile_tx- Performance profiling transmitterartnet_firmware_node- Firmware update node exampleartnet_firmware_server- Firmware update server exampleartnet_multiport- Multi-port exampleartnet_rdm_output- RDM output example
artnet_dmxconsole- Console-based DMX controllerartnet_dmxmonitor- DMX data monitor
artnet_usb- ArtNet to DMX node (Linux only, requires Enttec Open USB)
CMake will attempt to find libartnet using the following methods in order:
- pkg-config (if available) - searches for libartnet >= 1.1.0
- FetchContent - automatically downloads and builds from GitHub if not found
- Manual specification - uses paths provided via CMake variables
When libartnet is not found on the system:
- CMake downloads libartnet source from GitHub
- Configures and builds it using autotools (requires sh, autogen.sh, configure)
- Links the built library to example programs
Note: On Windows, this requires MSYS2/Cygwin environment for autotools support.
- Full support for all programs including artnet_usb
- Requires pthread library (automatically linked)
- ncurses programs available if libncurses-dev is installed
- Supports all programs except artnet_usb
- ncurses usually pre-installed
- May need to specify library paths if using Homebrew
- Supports all programs except artnet_usb
- Requires
ws2_32andwinmmlibraries (automatically linked by CMake) - ncurses programs only available in MSYS2 environment
- Recommend using MSYS2 MINGW64 for best compatibility
mkdir build && cd build
cmake ..
cmake --build .CMake will automatically download and build libartnet if not found.
mkdir build && cd build
cmake .. # Will use pkg-config to find system libartnet
cmake --build .mkdir build && cd build
cmake .. \
-DLIBARTNET_INCLUDE_DIRS="$HOME/libartnet/include" \
-DLIBARTNET_LIBRARIES="$HOME/libartnet/lib/libartnet.a"
cmake --build .# In MSYS2 MINGW64 terminal
mkdir build && cd build
cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release
ninjamkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64
cmake --build . --config Releasemkdir build && cd build
cmake .. -DBUILD_NCURSES_PROGS=OFF
cmake --build .After building, you can install the programs:
# System-wide installation (requires sudo/admin)
sudo cmake --install .
# User-local installation
cmake --install . --prefix $HOME/.local
# Windows installation
cmake --install . --prefix C:/Program\ Files/artnet-examples# Linux/macOS
./build/src/artnet_discover -a 192.168.1.100 -t 3
# Windows
.\build\src\Release\artnet_discover.exe -a 192.168.1.100 -t 3Options:
-a <ip>- IP address to bind to-t <seconds>- Time to wait for replies (default: 2)
# Set channel 1 to value 255
./build/src/artnet_setdmx -a 192.168.1.100 -p 0 -c 1 -d 255
# Fade channel 10 to 128 over 2 seconds
./build/src/artnet_setdmx -a 192.168.1.100 -c 10 -d 128 -f 2.0Options:
-a <ip>- IP address to send from-p <port>- Universe (port) address (0-4)-c <channel>- DMX channel (1-512)-d <value>- DMX value (0-255)-f <time>- Fade time in seconds
./build/src/artnet_dmxconsole -a 192.168.1.100 -s 2 -p 3Options:
-a <ip>- IP address-s <subnet>- Subnet address (0-15)-p <port>- Port address (0-15)
Universe address is calculated as: (subnet << 4) | port
Error: libartnet not found
Solutions:
- Install libartnet via package manager
- Build libartnet from source
- Let CMake auto-download (ensure Git is installed)
- Specify paths manually with
-DLIBARTNET_INCLUDE_DIRSand-DLIBARTNET_LIBRARIES
Error: CMake cannot find libartnet on Windows
Solution: Build libartnet in MSYS2 first:
# In MSYS2 MINGW64 terminal
git clone https://github.com/OpenLightingProject/libartnet.git
cd libartnet
./autogen.sh
./configure --prefix=/mingw64
make && make installError: undefined reference to '__imp_select'
Solution:
This should be automatically fixed by CMake linking ws2_32 library. If you still see this error:
- Ensure you're building in MSYS2 MINGW64 environment
- Check that
ws2_32is being linked (it's automatic in our CMakeLists.txt)
Error: #warning Please include winsock2.h before windows.h
Solution: This has been fixed in the source code. If you still see it:
- Make sure you're using the latest version
- The source files now include
winsock2.hbeforewindows.h
Error: ncurses programs are skipped
Solutions:
- Linux/macOS: Install ncurses development package
# Ubuntu/Debian sudo apt-get install libncurses-dev # Fedora/RHEL sudo dnf install ncurses-devel # macOS brew install ncurses
- Windows: ncurses programs require MSYS2 environment with ncurses package
- Disable ncurses programs: Use
-DBUILD_NCURSES_PROGS=OFF
Error: Git clone fails or autotools not found
Solutions:
- Check internet connection
- Install Git:
sudo apt-get install gitor download from git-scm.com - On Windows, ensure MSYS2 has autotools:
pacman -S autoconf automake libtool
- Install libartnet manually and use system version
Error: Compilation fails due to warnings treated as errors
Solution: Warnings are treated as errors by default. If you encounter platform-specific warnings:
- Report the warning as a bug
- Temporary workaround: Edit CMakeLists.txt to remove
-Werrorflag
For cross-compiling to different architectures:
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=/path/to/installcmake .. -DCMAKE_EXE_LINKER_FLAGS="-static"
cmake --build .cmake --build . --verbose
# Or with make
make VERBOSE=1# Use all CPU cores
cmake --build . --parallel
# Specify number of jobs
cmake --build . -j 4| Feature | CMake | Autotools |
|---|---|---|
| Configuration Speed | Fast | Slower |
| Windows Support | Native | Requires MSYS2/Cygwin |
| IDE Integration | Excellent | Limited |
| Parallel Builds | Default | Requires -j flag |
| Dependency Finding | Modern (pkg-config + FetchContent) | pkg-config only |
| Cross-Platform | Excellent | Good (Unix-focused) |
When contributing to the CMake build system:
- Test on multiple platforms (Linux, macOS, Windows)
- Ensure both system libartnet and FetchContent methods work
- Maintain compatibility with CMake 3.15+
- Update this documentation for any new options or changes
- CMake Documentation: https://cmake.org/documentation/
- libartnet Repository: https://github.com/OpenLightingProject/libartnet
- ArtNet Protocol: https://art-net.org.uk/
- MSYS2 Setup: https://www.msys2.org/
This project follows the same license as the original artnet-examples project (see COPYING file).
The CMake build system additions are also distributed under the same terms.