Skip to content

Commit

Permalink
Switch to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
bsongis committed Dec 21, 2015
1 parent c8358d7 commit 88841f6
Show file tree
Hide file tree
Showing 94 changed files with 1,578 additions and 981 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ install:

script:
- radio/util/commit-tests.sh
- mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug ../companion/src && cmake --build .
- mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DPCB=TARANIS .. && cmake --build .
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
project(OpenTX)

set(VERSION_MAJOR "2")
set(VERSION_MINOR "2")
set(VERSION_REVISION "0")
set(VERSION_SUFFIX $ENV{OPENTX_VERSION_SUFFIX})
set(VERSION_FAMILY ${VERSION_MAJOR}.${VERSION_MINOR})
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}${VERSION_SUFFIX})
message(STATUS "OpenTX ${VERSION}")

cmake_minimum_required(VERSION 2.8)

set(RADIO_DIRECTORY ${PROJECT_SOURCE_DIR}/radio)
set(RADIO_SRC_DIRECTORY ${RADIO_DIRECTORY}/src)
set(COMPANION_SRC_DIRECTORY ${PROJECT_SOURCE_DIR}/companion/src)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
include(Bitmaps)

add_subdirectory(${RADIO_SRC_DIRECTORY})
add_subdirectory(${COMPANION_SRC_DIRECTORY})
25 changes: 25 additions & 0 deletions cmake/Bitmaps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
macro(add_bitmaps_target targetname filter width format)
file(GLOB bitmaps ${filter})
foreach(bitmap ${bitmaps})
get_filename_component(target ${bitmap} NAME_WE)
set(target ${target}.lbm)
add_custom_command(
OUTPUT ${target}
COMMAND python ${RADIO_DIRECTORY}/util/img2lbm.py ${bitmap} ${target} ${width} ${format}
DEPENDS ${bitmap}
)
list(APPEND bitmaps_files ${target})
endforeach()
add_custom_target(${targetname} DEPENDS ${bitmaps_files})
endmacro(add_bitmaps_target)

macro(add_truetype_font_target radio name font size)
set(target ${RADIO_SRC_DIRECTORY}/fonts/${radio}/font_${name})
add_custom_command(
OUTPUT ${target}.png
OUTPUT ${target}.specs
COMMAND ${RADIO_DIRECTORY}/util/font2png.py ${font} ${size} False ${target}
WORKING_DIRECTORY ${RADIO_SRC_DIRECTORY}
)
add_custom_target(ttf_${radio}_${name} DEPENDS ${target}.png ${target}.specs)
endmacro(add_truetype_font_target)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions cmake/Macros.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
macro(today RESULT)
if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3" ${RESULT} ${${RESULT}})
elseif(UNIX)
execute_process(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(....)-(..)-(..).*" "\\1-\\2-\\3" ${RESULT} ${${RESULT}})
else(WIN32)
message(SEND_ERROR "date not implemented")
set(${RESULT} 00.00.0000)
endif(WIN32)
endmacro(today)

macro(now RESULT)
if(WIN32)
execute_process(COMMAND "cmd" " /C time /T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..):(..).*" "\\1:\\2:00" ${RESULT} ${${RESULT}})
elseif(UNIX)
execute_process(COMMAND "date" "+%H:%M:%S" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..):(..):(..).*" "\\1:\\2:\\3" ${RESULT} ${${RESULT}})
else(WIN32)
message(SEND_ERROR "time not implemented")
set(${RESULT} 00:00:00)
endif(WIN32)
endmacro(now)

macro(git_id RESULT)
if(WIN32)
execute_process(COMMAND "cmd" " /C git --git-dir=${PROJECT_SOURCE_DIR}/.git rev-parse HEAD" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}})
elseif(UNIX)
execute_process(COMMAND "git" "--git-dir=${PROJECT_SOURCE_DIR}/.git" "rev-parse" "HEAD" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}})
else(WIN32)
message(SEND_ERROR "Git ID implemented")
set(${RESULT} 0)
endif(WIN32)
endmacro(git_id)
Loading

0 comments on commit 88841f6

Please sign in to comment.