Skip to content

Commit 5489b84

Browse files
committed
Improvements to cmake.
1 parent 5e92e1f commit 5489b84

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+191
-616
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ serialsent.raw
66
CMakeFiles
77
CMakeCache.txt
88
cmake_install.cmake
9+
build

ArduCopter/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
arducopter.cpp

ArduCopter/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ set(${FIRMWARE_NAME}_LIBS
126126
c
127127
m
128128
)
129-
SET_TARGET_PROPERTIES(AP_Math PROPERTIES LINKER_LANGUAGE CXX)
130-
131129

132130
#${CONSOLE_PORT}
133131
set(${FIRMWARE_NAME}_PORT COM2) # Serial upload port

ArduPlane/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ArduPlane.cpp

ArduPlane/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@ set(${FIRMWARE_NAME}_LIBS
126126
c
127127
m
128128
)
129-
SET_TARGET_PROPERTIES(AP_Math PROPERTIES LINKER_LANGUAGE CXX)
130-
131129

132130
#${CONSOLE_PORT}
133131
set(${FIRMWARE_NAME}_PORT COM2) # Serial upload port

apo/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
apo.cpp

apo/CMakeLists.txt

+45-48
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,29 @@
1-
#=============================================================================#
2-
# Author: Sebastian Rohde #
3-
# Date: 30.08.2011 #
4-
#=============================================================================#
1+
cmake_minimum_required(VERSION 2.6)
52

3+
set(CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../")
4+
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
5+
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Arduino.cmake)
66

7-
#====================================================================#
8-
# Settings #
9-
#====================================================================#
10-
set(FIRMWARE_NAME apo)
7+
string(REGEX REPLACE ".*/" "" PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR})
8+
project(${PROJECT_NAME} C CXX)
9+
set(FIRMWARE_NAME ${PROJECT_NAME})
1110

12-
set(${FIRMWARE_NAME}_BOARD ${BOARD}) # Arduino Target board
11+
set (CMAKE_CXX_SOURCE_FILE_EXTENSIONS pde)
1312

14-
set(${FIRMWARE_NAME}_SKETCHES
15-
apo.pde
16-
) # Firmware sketches
17-
18-
set(${FIRMWARE_NAME}_SRCS
19-
) # Firmware sources
20-
21-
set(${FIRMWARE_NAME}_HDRS
22-
ControllerPlane.h
23-
ControllerQuad.h
24-
PlaneEasystar.h
25-
QuadArducopter.h
26-
QuadMikrokopter.h
27-
) # Firmware sources
13+
find_package(Arduino 22 REQUIRED)
2814

29-
set(${FIRMWARE_NAME}_LIBS
30-
m
31-
APO
32-
FastSerial
33-
AP_Common
34-
GCS_MAVLink
35-
AP_GPS
36-
APM_RC
37-
AP_DCM
38-
AP_ADC
39-
AP_Compass
40-
AP_IMU
41-
AP_RangeFinder
42-
APM_BMP085
43-
ModeFilter
44-
)
45-
15+
if (NOT DEFINED BOARD)
16+
message(STATUS "board not defined, assuming mega, use cmake -DBOARD=mega2560 , etc. to specify")
17+
set(BOARD "mega")
18+
endif()
19+
message(STATUS "Board configured as: ${BOARD}")
4620

47-
#${CONSOLE_PORT}
48-
set(${FIRMWARE_NAME}_PORT COM2) # Serial upload port
49-
set(${FIRMWARE_NAME}_SERIAL putty -serial COM2 -sercfg 57600,8,n,1,X ) # Serial terminal cmd
21+
# need to configure based on host operating system
22+
set(${PROJECT_NAME}_PORT COM2)
23+
set(${PROJECT_NAME}_SERIAL putty -serial COM2 -sercfg 57600,8,n,1,X )
5024

5125
include_directories(
26+
${ARDUINO_LIBRARIES_PATH}/Wire
5227
${CMAKE_SOURCE_DIR}/libraries/APO
5328
${CMAKE_SOURCE_DIR}/libraries/AP_Common
5429
${CMAKE_SOURCE_DIR}/libraries/FastSerial
@@ -63,12 +38,34 @@ ${CMAKE_SOURCE_DIR}/libraries/APM_RC
6338
${CMAKE_SOURCE_DIR}/libraries/GCS_MAVLink
6439
${CMAKE_SOURCE_DIR}/libraries/APM_BMP085
6540
)
66-
#====================================================================#
67-
# Target generation #
68-
#====================================================================#
69-
generate_arduino_firmware(${FIRMWARE_NAME})
41+
42+
add_subdirectory(../libraries "${CMAKE_CURRENT_BINARY_DIR}/libs")
43+
file(WRITE ${PROJECT_NAME}.cpp "// Do not edit")
44+
set(${PROJECT_NAME}_BOARD ${BOARD})
45+
file(GLOB ${PROJECT_NAME}_SKETCHES *.pde)
46+
file(GLOB ${PROJECT_NAME}_SRCS *.cpp)
47+
file(GLOB ${PROJECT_NAME}_HDRS *.h)
48+
set(${PROJECT_NAME}_LIBS
49+
c
50+
m
51+
APO
52+
FastSerial
53+
AP_Common
54+
GCS_MAVLink
55+
AP_GPS
56+
APM_RC
57+
AP_DCM
58+
AP_ADC
59+
AP_Compass
60+
AP_IMU
61+
AP_RangeFinder
62+
APM_BMP085
63+
ModeFilter
64+
)
65+
66+
generate_arduino_firmware(${PROJECT_NAME})
7067

7168
install(FILES
72-
${CMAKE_CURRENT_BINARY_DIR}/${FIRMWARE_NAME}.hex
69+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.hex
7370
DESTINATION bin
7471
)

apo/apo.pde

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Libraries
2+
#include <WProgram.h>
23
#include <FastSerial.h>
34
#include <AP_Common.h>
45
#include <APM_RC.h>

cmake/modules/ApmMakeLib.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
string(REGEX REPLACE ".*/" "" LIB_NAME ${CMAKE_CURRENT_SOURCE_DIR})
2+
#message(STATUS "building lib: ${LIB_NAME}")
3+
file(GLOB ${LIB_NAME}_SRCS *.cpp)
4+
file(GLOB ${LIB_NAME}_HDRS *.h)
5+
set(${LIB_NAME}_BOARD ${BOARD})
6+
generate_arduino_library(${LIB_NAME})
7+
set_target_properties(${LIB_NAME} PROPERTIES LINKER_LANGUAGE CXX)

cmake/modules/ApmMakeSketch.cmake

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
cmake_minimum_required(VERSION 2.6)
2+
3+
set(CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}/../")
4+
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
5+
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Arduino.cmake)
6+
7+
string(REGEX REPLACE ".*/" "" PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR})
8+
project(${PROJECT_NAME} C CXX)
9+
10+
set (CMAKE_CXX_SOURCE_FILE_EXTENSIONS pde)
11+
12+
find_package(Arduino 22 REQUIRED)
13+
14+
if (NOT DEFINED BOARD)
15+
message(STATUS "board not defined, assuming mega, use cmake -DBOARD=mega2560 , etc. to specify")
16+
set(BOARD "mega")
17+
endif()
18+
message(STATUS "Board configured as: ${BOARD}")
19+
20+
# need to configure based on host operating system
21+
set(${PROJECT_NAME}_PORT COM2)
22+
set(${PROJECT_NAME}_SERIAL putty -serial COM2 -sercfg 57600,8,n,1,X )
23+
24+
include_directories(
25+
${ARDUINO_LIBRARIES_PATH}/Wire
26+
${CMAKE_SOURCE_DIR}/libraries/APO
27+
${CMAKE_SOURCE_DIR}/libraries/AP_Common
28+
${CMAKE_SOURCE_DIR}/libraries/FastSerial
29+
${CMAKE_SOURCE_DIR}/libraries/ModeFilter
30+
${CMAKE_SOURCE_DIR}/libraries/AP_Compass
31+
${CMAKE_SOURCE_DIR}/libraries/AP_RangeFinder
32+
${CMAKE_SOURCE_DIR}/libraries/AP_GPS
33+
${CMAKE_SOURCE_DIR}/libraries/AP_IMU
34+
${CMAKE_SOURCE_DIR}/libraries/AP_ADC
35+
${CMAKE_SOURCE_DIR}/libraries/AP_DCM
36+
${CMAKE_SOURCE_DIR}/libraries/APM_RC
37+
${CMAKE_SOURCE_DIR}/libraries/GCS_MAVLink
38+
${CMAKE_SOURCE_DIR}/libraries/APM_BMP085
39+
)
40+
41+
add_subdirectory(../libraries "${CMAKE_CURRENT_BINARY_DIR}/libs")
42+
43+
set(${PROJECT_NAME}_BOARD ${BOARD})
44+
file(GLOB ${PROJECT_NAME}_SKETCHES *.pde)
45+
file(GLOB ${PROJECT_NAME}_SRCS *.cpp)
46+
file(GLOB ${PROJECT_NAME}_HDRS *.h)
47+
set(${PROJECT_NAME}_LIBS
48+
c
49+
m
50+
APO
51+
FastSerial
52+
AP_Common
53+
GCS_MAVLink
54+
AP_GPS
55+
APM_RC
56+
AP_DCM
57+
AP_ADC
58+
AP_Compass
59+
AP_IMU
60+
AP_RangeFinder
61+
APM_BMP085
62+
ModeFilter
63+
)
64+
65+
66+
67+
68+
69+
generate_arduino_firmware(${PROJECT_NAME})
70+
71+
install(FILES
72+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.hex
73+
DESTINATION bin
74+
)

libraries/APM_BMP085/CMakeLists.txt

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1 @@
1-
set(LIB_NAME APM_BMP085)
2-
3-
set(${LIB_NAME}_SRCS
4-
APM_BMP085.cpp
5-
) # Firmware sources
6-
7-
set(${LIB_NAME}_HDRS
8-
APM_BMP085.h
9-
)
10-
11-
include_directories(
12-
13-
-
14-
#${CMAKE_SOURCE_DIR}/libraries/AP_Math
15-
#${CMAKE_SOURCE_DIR}/libraries/AP_Common
16-
#${CMAKE_SOURCE_DIR}/libraries/FastSerial
17-
#
18-
)
19-
20-
set(${LIB_NAME}_BOARD ${BOARD})
21-
22-
generate_arduino_library(${LIB_NAME})
1+
include(ApmMakeLib)

libraries/APM_PI/CMakeLists.txt

+1-24
Original file line numberDiff line numberDiff line change
@@ -1,24 +1 @@
1-
set(LIB_NAME APM_PI)
2-
3-
set(${LIB_NAME}_SRCS
4-
APM_PI.cpp
5-
#AP_OpticalFlow_ADNS3080.cpp
6-
) # Firmware sources
7-
8-
set(${LIB_NAME}_HDRS
9-
APM_PI.h
10-
#AP_OpticalFlow_ADNS3080.h
11-
)
12-
13-
include_directories(
14-
15-
-
16-
#${CMAKE_SOURCE_DIR}/libraries/AP_Math
17-
${CMAKE_SOURCE_DIR}/libraries/AP_Common
18-
#${CMAKE_SOURCE_DIR}/libraries/FastSerial
19-
#
20-
)
21-
22-
set(${LIB_NAME}_BOARD ${BOARD})
23-
24-
generate_arduino_library(${LIB_NAME})
1+
include(ApmMakeLib)

libraries/APM_PerfMon/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include(ApmMakeLib)

libraries/APM_RC/CMakeLists.txt

+1-22
Original file line numberDiff line numberDiff line change
@@ -1,22 +1 @@
1-
set(LIB_NAME APM_RC)
2-
3-
set(${LIB_NAME}_SRCS
4-
APM_RC.cpp
5-
) # Firmware sources
6-
7-
set(${LIB_NAME}_HDRS
8-
APM_RC.h
9-
)
10-
11-
include_directories(
12-
13-
-
14-
#${CMAKE_SOURCE_DIR}/libraries/AP_Math
15-
#${CMAKE_SOURCE_DIR}/libraries/AP_Common
16-
#${CMAKE_SOURCE_DIR}/libraries/FastSerial
17-
#
18-
)
19-
20-
set(${LIB_NAME}_BOARD ${BOARD})
21-
22-
generate_arduino_library(${LIB_NAME})
1+
include(ApmMakeLib)

libraries/APO/CMakeLists.txt

+1-39
Original file line numberDiff line numberDiff line change
@@ -1,39 +1 @@
1-
set(LIB_NAME APO)
2-
3-
set(${LIB_NAME}_SRCS
4-
AP_Autopilot.cpp
5-
AP_CommLink.cpp
6-
AP_Controller.cpp
7-
AP_Guide.cpp
8-
AP_HardwareAbstractionLayer.cpp
9-
AP_MavlinkCommand.cpp
10-
AP_Navigator.cpp
11-
AP_RcChannel.cpp
12-
APO.cpp
13-
) # Firmware sources
14-
15-
set(${LIB_NAME}_HDRS
16-
AP_Autopilot.h
17-
AP_CommLink.h
18-
AP_Controller.h
19-
AP_Guide.h
20-
AP_HardwareAbstractionLayer.h
21-
AP_MavlinkCommand.h
22-
AP_Navigator.h
23-
AP_RcChannel.h
24-
AP_Var_keys.h
25-
APO.h
26-
constants.h
27-
template.h
28-
)
29-
30-
include_directories(
31-
# ${CMAKE_SOURCE_DIR}/libraries/AP_Common
32-
${CMAKE_SOURCE_DIR}/libraries/FastSerial
33-
${CMAKE_SOURCE_DIR}/libraries/ModeFilter
34-
#
35-
)
36-
37-
set(${LIB_NAME}_BOARD ${BOARD})
38-
39-
generate_arduino_library(${LIB_NAME})
1+
include(ApmMakeLib)

libraries/AP_ADC/CMakeLists.txt

+1-26
Original file line numberDiff line numberDiff line change
@@ -1,26 +1 @@
1-
set(LIB_NAME AP_ADC)
2-
3-
set(${LIB_NAME}_SRCS
4-
AP_ADC_HIL.cpp
5-
AP_ADC_ADS7844.cpp
6-
AP_ADC.cpp
7-
) # Firmware sources
8-
9-
set(${LIB_NAME}_HDRS
10-
AP_ADC_HIL.h
11-
AP_ADC_ADS7844.h
12-
AP_ADC.h
13-
)
14-
15-
include_directories(
16-
17-
-
18-
#${CMAKE_SOURCE_DIR}/libraries/AP_Math
19-
#${CMAKE_SOURCE_DIR}/libraries/AP_Common
20-
#${CMAKE_SOURCE_DIR}/libraries/FastSerial
21-
#
22-
)
23-
24-
set(${LIB_NAME}_BOARD ${BOARD})
25-
26-
generate_arduino_library(${LIB_NAME})
1+
include(ApmMakeLib)

0 commit comments

Comments
 (0)