1- cmake_minimum_required ( VERSION 2.6 )
1+ cmake_minimum_required ( VERSION 3.5 )
2+ set ( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR} /../CMakeModules" )
3+ include ( add_submodule )
4+
5+ set ( CMAKE_CXX_STANDARD 17 )
26
37# Command line options
48SET ( board "rpi" CACHE BOOL "board" )
@@ -10,6 +14,7 @@ if ( NOT ${board} MATCHES OFF AND NOT ${board} MATCHES "generic" )
1014 set ( CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR} /../Toolchain-${board} .cmake )
1115endif ()
1216
17+ enable_language ( C CXX ASM )
1318project ( controller_rc )
1419
1520# Set compiler options
@@ -45,56 +50,93 @@ include_directories( boards/${board} )
4550include_directories ( ${CMAKE_SOURCE_DIR} )
4651include_directories ( ${CMAKE_BINARY_DIR} )
4752add_definitions ( -DBOARD="${board} " -DBOARD_${board} )
48- if ( ${USE_MINISTD} MATCHES TRUE )
49- add_definitions ( -DSTD=ministd )
50- else ()
51- add_definitions ( -DSTD=std )
52- endif ()
5353
54- include_directories ( ${CMAKE_SOURCE_DIR} /../libdebug )
55- include_directories ( ${CMAKE_SOURCE_DIR} /../libcontroller )
56- include_directories ( ${CMAKE_SOURCE_DIR} /../libcontroller /links )
54+ include_directories ( ${CMAKE_SOURCE_DIR} /../lib/debug )
55+ include_directories ( ${CMAKE_SOURCE_DIR} /../lib/controller )
56+ include_directories ( ${CMAKE_SOURCE_DIR} /../lib /links )
5757if ( ${rawwifi} MATCHES "1" OR ${rawwifi} MATCHES "yes" OR ${rawwifi} MATCHES "true" )
58- include_directories ( ${CMAKE_SOURCE_DIR} /../librawwifi )
59- set ( RAWWIFI_LIBS rawwifi -lpcap )
58+ include_directories ( ${CMAKE_SOURCE_DIR} /../lib/rawwifi )
59+ # set( RAWWIFI_LIBS rawwifi -lpcap )
6060 add_definitions ( -DBUILD_rawwifi )
6161endif ()
62+
63+ include_directories ( ${CMAKE_SOURCE_DIR} /../lib/luacore/src )
6264include_directories ( ${CMAKE_SOURCE_DIR} /../external/LuaJIT-2.0.4/src )
63- add_subdirectory ( ${CMAKE_SOURCE_DIR} /../libcontroller libcontroller )
64- add_subdirectory ( ${CMAKE_SOURCE_DIR} /../libdebug libdebug )
65-
66- add_custom_target ( libluajit_static COMMAND bash ${CMAKE_SOURCE_DIR} /../external/build_luajit.sh ${CMAKE_BINARY_DIR} ${CMAKE_C_COMPILER} ${CMAKE_ASM_COMPILER} ${CROSS} strip "-m32" )
67- add_custom_target ( ui_headers COMMAND
68- ${UIC} ${CMAKE_SOURCE_DIR} /ui/main.ui > ${CMAKE_BINARY_DIR} /ui_main.h
69- && ${UIC} ${CMAKE_SOURCE_DIR} /ui/window.ui > ${CMAKE_BINARY_DIR} /ui_window.h
70- && ${UIC} ${CMAKE_SOURCE_DIR} /ui/calibrate.ui > ${CMAKE_BINARY_DIR} /ui_calibrate.h
71- && ${UIC} ${CMAKE_SOURCE_DIR} /ui/camera.ui > ${CMAKE_BINARY_DIR} /ui_camera.h
72- && ${UIC} ${CMAKE_SOURCE_DIR} /ui/network.ui > ${CMAKE_BINARY_DIR} /ui_network.h
73- && ${UIC} ${CMAKE_SOURCE_DIR} /ui/settings.ui > ${CMAKE_BINARY_DIR} /ui_settings.h
74- )
65+ add_submodule( controller )
66+ add_submodule( debug )
7567
76- # add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/rc_data.cpp COMMAND ${RCC} ${CMAKE_SOURCE_DIR}/ui/data.qrc > ${CMAKE_BINARY_DIR}/rc_data.cpp WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" )
77- add_custom_command ( OUTPUT ${CMAKE_BINARY_DIR} /MainWindow.moc.cpp COMMAND ${MOC} ${CMAKE_SOURCE_DIR} /ui/MainWindow.h > ${CMAKE_BINARY_DIR} /MainWindow.moc.cpp WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR} " )
7868
7969file ( GLOB_RECURSE BOARD_SOURCES boards/${board} /*.cpp boards/${board} /*.c )
8070file ( GLOB_RECURSE ADCS_SOURCES ADCs/*.cpp ADCs/*.c )
8171
72+ file ( GLOB HEADERS
73+ ${CMAKE_SOURCE_DIR} /*.h
74+ ${CMAKE_SOURCE_DIR} /boards/rpi/*.h
75+ ${CMAKE_SOURCE_DIR} /../lib/controller/*.h
76+ ${CMAKE_SOURCE_DIR} /../lib/links/*.h
77+ )
78+
79+ set_source_files_properties ( ${CMAKE_BINARY_DIR} /lua_init.cpp PROPERTIES GENERATED TRUE )
80+ set_source_files_properties ( ${CMAKE_BINARY_DIR} /rc_data.cpp PROPERTIES GENERATED TRUE )
81+
82+
83+ add_custom_command (
84+ OUTPUT ${CMAKE_BINARY_DIR} /lua_init.cpp
85+ DEPENDS ${CMAKE_SOURCE_DIR} /../lib/luacore/classes.auto.lua ${HEADERS}
86+ COMMAND ${CMAKE_SOURCE_DIR} /../lib/luacore/classes.auto.lua --init=lua_init --output ="${CMAKE_BINARY_DIR} /lua_init.cpp" ${HEADERS}
87+ )
88+ add_custom_command (
89+ OUTPUT
90+ ${CMAKE_BINARY_DIR} /ui_main.h
91+ ${CMAKE_BINARY_DIR} /ui_window.h
92+ ${CMAKE_BINARY_DIR} /ui_calibrate.h
93+ ${CMAKE_BINARY_DIR} /ui_camera.h
94+ ${CMAKE_BINARY_DIR} /ui_network.h
95+ ${CMAKE_BINARY_DIR} /ui_settings.h
96+ COMMAND
97+ ${UIC} ${CMAKE_SOURCE_DIR} /ui/main.ui > ${CMAKE_BINARY_DIR} /ui_main.h
98+ && ${UIC} ${CMAKE_SOURCE_DIR} /ui/window.ui > ${CMAKE_BINARY_DIR} /ui_window.h
99+ && ${UIC} ${CMAKE_SOURCE_DIR} /ui/calibrate.ui > ${CMAKE_BINARY_DIR} /ui_calibrate.h
100+ && ${UIC} ${CMAKE_SOURCE_DIR} /ui/camera.ui > ${CMAKE_BINARY_DIR} /ui_camera.h
101+ && ${UIC} ${CMAKE_SOURCE_DIR} /ui/network.ui > ${CMAKE_BINARY_DIR} /ui_network.h
102+ && ${UIC} ${CMAKE_SOURCE_DIR} /ui/settings.ui > ${CMAKE_BINARY_DIR} /ui_settings.h
103+ DEPENDS
104+ ${CMAKE_SOURCE_DIR} /ui/main.ui
105+ ${CMAKE_SOURCE_DIR} /ui/window.ui
106+ ${CMAKE_SOURCE_DIR} /ui/calibrate.ui
107+ ${CMAKE_SOURCE_DIR} /ui/camera.ui
108+ ${CMAKE_SOURCE_DIR} /ui/network.ui
109+ ${CMAKE_SOURCE_DIR} /ui/settings.ui
110+ )
111+ add_custom_target (ui_headers
112+ DEPENDS
113+ ${CMAKE_BINARY_DIR} /ui_main.h
114+ ${CMAKE_BINARY_DIR} /ui_window.h
115+ ${CMAKE_BINARY_DIR} /ui_calibrate.h
116+ ${CMAKE_BINARY_DIR} /ui_camera.h
117+ ${CMAKE_BINARY_DIR} /ui_network.h
118+ ${CMAKE_BINARY_DIR} /ui_settings.h
119+ )
120+
121+ add_custom_command ( OUTPUT ${CMAKE_BINARY_DIR} /rc_data.cpp COMMAND ${RCC} ${CMAKE_SOURCE_DIR} /ui/data.qrc > ${CMAKE_BINARY_DIR} /rc_data.cpp WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR} " )
122+ add_custom_command ( OUTPUT ${CMAKE_BINARY_DIR} /MainWindow.moc.cpp COMMAND ${MOC} ${CMAKE_SOURCE_DIR} /ui/MainWindow.h > ${CMAKE_BINARY_DIR} /MainWindow.moc.cpp WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR} " )
123+
82124add_executable ( controller_rc
83- main.cpp
84- Config.cpp
85- ui/GlobalUI.cpp
86- ui/MainWindow.cpp
87- ${CMAKE_BINARY_DIR} /rc_data.cpp
88- ${CMAKE_BINARY_DIR} /MainWindow.moc.cpp
89- ${ADCS_SOURCES}
90- ${BOARD_SOURCES}
91- )
125+ main.cpp
126+ Config.cpp
127+ ui/GlobalUI.cpp
128+ ui/MainWindow.cpp
129+ ${CMAKE_BINARY_DIR} /rc_data.cpp
130+ ${CMAKE_BINARY_DIR} /MainWindow.moc.cpp
131+ ${CMAKE_BINARY_DIR} /lua_init.cpp
132+ ${ADCS_SOURCES}
133+ ${BOARD_SOURCES}
134+ )
92135
93136add_dependencies ( controller_rc controller )
94- add_dependencies ( controller_rc libluajit_static )
95137add_dependencies ( controller_rc ui_headers )
96138
97139
98- target_link_libraries ( controller_rc -L./ controller libdebug libluajit_static.a -lrt -ldl ${RAWWIFI_LIBS} -lz pthread ${BOARD_LIBS} )
140+ target_link_libraries ( controller_rc -L./ controller debuglib -lrt -ldl ${RAWWIFI_LIBS} -lz pthread ${BOARD_LIBS} )
99141
100142install ( TARGETS controller_rc RUNTIME DESTINATION bin )
0 commit comments