Skip to content

Commit 91d52eb

Browse files
committed
Added CMake build system contributed by Tyler Kinney.
1 parent 0aa6650 commit 91d52eb

File tree

4 files changed

+176
-13
lines changed

4 files changed

+176
-13
lines changed

.github/workflows/cmake.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build (Windows, CMake)
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
name: Build with Visual Studio 2022
12+
runs-on: windows-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up CMake
19+
uses: jwlawson/actions-setup-cmake@v2
20+
21+
- name: Configure (CMake)
22+
run: |
23+
cmake -S src -B build -G "Visual Studio 17 2022" -A x64
24+
25+
- name: Build
26+
run: cmake --build build --config Release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ doc8643AircraftTypes.csv
3737
doc8643Manufacturers.csv
3838
testfiles/modes1.bin.png
3939
waterfall/
40+
src/build

README.md

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,46 @@ and added some more references and screen-shots. But in the source-code I've don
4646

4747
## Building
4848

49+
This project can be built in 3 ways; using CMake, GNU-make or MSBuild / Visual-Studio.
50+
The shell could not matter; CMD, TakeCommand, Cmder or PowerShell should work. <br>
4951
Assuming you have downloaded (or `git clone`-d) this package to `c:\dev\Dump1090`,
50-
then `cd c:\dev\Dump1090\src` and do:
51-
52-
* Using GNU-make, type:
53-
* `c:\dev\Dump1090\src> make -f Makefile.Windows CC=cl` (or `CC=clang-cl`).
54-
* or for MinGW-w64, type:
55-
* `c:\dev\Dump1090\src> make -f Makefile.MinGW`.
56-
* Or using Visual Studio tools:
57-
* `c:\dev\Dump1090\src> msbuild -p:Configuration=Release -p:Platform="x86" Dump1090.sln`.
58-
* or start the Visual Studio IDE, open `Dump1090.sln`, right-click and `Build Solution`. <nl>
59-
The project may have to be retargeted. *Devenv* would do this automatically and print <nl>
60-
`Configuration 'Release|x64': changing Platform Toolset to 'v143' (was 'v142')` when finished.
61-
* Build `setup.exe` by moving into the `tools/` directory with `cd ..\tools`, and running `.\generate-setupfile.bat`
62-
(ensure Rust is installed)
52+
then `cd c:\dev\Dump1090\src`.
53+
54+
**Building with CMake:**
55+
56+
* CMake >= 3.24 is required.
57+
* Visual Studio 2022 (or newer) with C++ workload is required.
58+
* Steps:
59+
* Create a build directory and configure the project using CMake:
60+
```powershell
61+
mkdir build
62+
cd build
63+
cmake .. -G "Visual Studio 17 2022" -A x64
64+
```
65+
* Build it:
66+
```powershell
67+
cmake --build . --config Release
68+
```
69+
* After building, the executable will be placed in the parent directory:
70+
```
71+
c:\dev\Dump1090\dump1090.exe
72+
```
73+
74+
**Building with GNU-Make:**
75+
76+
* `c:\dev\Dump1090\src> make -f Makefile.Windows CC=cl` (or `CC=clang-cl`).
77+
* or for MinGW-w64, type:
78+
* `c:\dev\Dump1090\src> make -f Makefile.MinGW`.
79+
80+
**Building with Visual Studio tools:**
81+
82+
* `c:\dev\Dump1090\src> msbuild -p:Configuration=Release -p:Platform="x86" Dump1090.sln`.
83+
* or start the Visual Studio IDE, open `Dump1090.sln`, right-click and `Build Solution`. <nl>
84+
The project may have to be retargeted. *Devenv* would do this automatically and print <nl>
85+
`Configuration 'Release|x64': changing Platform Toolset to 'v143' (was 'v142')` when finished.
86+
87+
Build `setup.exe` by moving into the `tools/` directory with `cd ..\tools`, and running `.\generate-setupfile.bat`
88+
(ensure Rust is installed)
6389
6490
## Normal usage
6591

src/CMakeLists.txt

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#
2+
# CMake build system contributed by Tyler Kinney.
3+
#
4+
# Ref: https://github.com/gvanem/Dump1090/pull/35
5+
#
6+
cmake_minimum_required(VERSION 3.20)
7+
project(dump1090 LANGUAGES C)
8+
9+
# Windows-only check
10+
if(NOT WIN32)
11+
message(FATAL_ERROR "dump1090 is Windows-only")
12+
endif()
13+
14+
# Define source files
15+
set(SOURCES
16+
aircraft.c
17+
airports.c
18+
cfg_file.c
19+
convert.c
20+
cpr.c
21+
crc.c
22+
csv.c
23+
demod-2000.c
24+
demod-2400.c
25+
demod-2400AC.c
26+
demod-8000.c
27+
dump1090.c
28+
fifo.c
29+
geo.c
30+
infile.c
31+
interactive.c
32+
location.c
33+
misc.c
34+
net_io.c
35+
pconsole.c
36+
smartlist.c
37+
speech.c
38+
externals/mongoose.c
39+
externals/AirSpy/airspy.c
40+
externals/PDC-Mod/amalgamation.c
41+
externals/sqlite3.c
42+
externals/zip.c
43+
externals/rtl-sdr/librtlsdr.c
44+
externals/rtl-sdr/trace.c
45+
externals/rtl-sdr/tuner_e4k.c
46+
externals/rtl-sdr/tuner_fc001x.c
47+
externals/rtl-sdr/tuner_fc2580.c
48+
externals/rtl-sdr/tuner_r82xx.c
49+
externals/SDRplay/sdrplay.c
50+
)
51+
52+
# Include directories
53+
include_directories(
54+
.
55+
./externals
56+
./externals/PDC-Mod
57+
)
58+
59+
# Preprocessor define and forced include
60+
add_definitions(-DDOING_MSBUILD)
61+
add_compile_options(/FIdump1090_config.h)
62+
63+
# Create executable
64+
add_executable(dump1090 ${SOURCES})
65+
66+
# Compiler options per configuration
67+
target_compile_options(dump1090 PRIVATE
68+
$<$<CONFIG:Debug>:/MDd /W4 /Zi /Od>
69+
$<$<CONFIG:Release>:/MD /W4 /Zi>
70+
)
71+
72+
# Link Windows libraries
73+
target_link_libraries(dump1090 PRIVATE
74+
advapi32
75+
dnsapi
76+
iphlpapi
77+
ole32
78+
user32
79+
setupapi
80+
shlwapi
81+
winusb
82+
ws2_32
83+
)
84+
85+
# Console subsystem
86+
set_target_properties(dump1090 PROPERTIES
87+
LINK_FLAGS "/SUBSYSTEM:CONSOLE"
88+
OUTPUT_NAME "dump1090"
89+
)
90+
91+
# Set machine type based on architecture
92+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
93+
set_target_properties(dump1090 PROPERTIES LINK_FLAGS "${CMAKE_LINK_FLAGS} /MACHINE:X64")
94+
else()
95+
set_target_properties(dump1090 PROPERTIES LINK_FLAGS "${CMAKE_LINK_FLAGS} /MACHINE:X86")
96+
endif()
97+
98+
# Enable PDB generation
99+
set_target_properties(dump1090 PROPERTIES
100+
COMPILE_PDB_NAME "dump1090"
101+
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
102+
)
103+
104+
# Post-build: copy executable to ../dump1090.exe
105+
add_custom_command(TARGET dump1090 POST_BUILD
106+
COMMAND ${CMAKE_COMMAND} -E copy
107+
$<TARGET_FILE:dump1090>
108+
${CMAKE_CURRENT_SOURCE_DIR}/../dump1090.exe
109+
COMMENT "Copying dump1090.exe to ../dump1090.exe"
110+
)

0 commit comments

Comments
 (0)