Embedded app for pilot to interact with boat electrical systems - runs on a RPi 4 + touchscreen.
Before doing anything, make sure to create a new file called CMakeLists.config.txt
in the same directory as CMakeLists.txt
with the below template.
cmake_minimum_required(VERSION 3.9)
###### Platform Specific Options
## Ensure that you have properly configurated your .vscode cpp configuration file. See repo README.md for more info.
## Raspberry Pi 4 Options Only
# includes all libs
# include_directories("/usr/include")
# link_directories("/usr/lib")
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
## QT Options
set(QT_INSTALL_PATH "[insert Qt installation path]")
set(CMAKE_PREFIX_PATH "${QT_INSTALL_PATH}") # <--- MAKE SURE HOMEBREW INSTALLATION FOR QT IS x86_64 (arm is not supported for dependencies)
## ZMQ Options
set(ZMQ_VERSION "4.3.4") # <-- sometimes not needed
set(ZMQ_INSTALL_PATH "[insert ZMQ installation path]")
include_directories("${ZMQ_INSTALL_PATH}/include")
link_directories("${ZMQ_INSTALL_PATH}/lib")
## Boost Options
set(BOOST_INSTALL_PATH "[insert Boost installation path]")
include_directories("${BOOST_INSTALL_PATH}/include")
set(Boost_INCLUDE_DIR "${BOOST_INSTALL_PATH}/include")
## QGeoView Options
set(QGEOVIEW_INSTALL_PATH "[insert QGeoView installation path]")
include_directories("${QGEOVIEW_INSTALL_PATH}/include")
link_directories("${QGEOVIEW_INSTALL_PATH}/lib")
## msgpack Options (Sometimes not needed, uses "msgpack-config.cmake" instead of include and lib folders)
# set(MSGPACK_INSTALL_PATH "${PROJECT_SOURCE_DIR}/3rd_party/msgpack")
# add_subdirectory("${MSGPACK_INSTALL_PATH}")
# include_directories("${MSGPACK_INSTALL_PATH}/include/msgpack")
######
# NOTE: IF YOU GET AN ERROR ABOUT "Library not loaded" referenced from "libEsriCommonQt.dylib",
# create a symbolic link between the "Frameworks" folder in the Qt installation folder (QT_INSTALL_PATH)
# and the "${PROJECT_SOURCE_DIR}/build" folder generated by CMAKE such that "${PROJECT_SOURCE_DIR}/build/Frameworks" exists
# For MacOS, you can do this: https://apple.stackexchange.com/a/115648/
# (for instance ln -s /usr/local/Homebrew/Cellar/qt@5/5.15.2_2/Frameworks Users/richy/Documents/GitHub/pilotapp/pilotapp/build)
######
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_SOURCE_DIR ${PROJECT_SOURCE_DIR})
## Set CMAKE Arch to x86_64 [depricated]
#set(CMAKE_GENERATOR_PLATFORM x86_64)
#set(CMAKE_SYSTEM_PROCESSOR x86_64)
#set(CMAKE_OSX_ARCHITECTURES x86_64)
This file will include all the CMake configurations specific to your system. Make sure to set the appropriate library paths accordingly.
-
Visual Studio Build Tools (Scoll down to All Downloads->Tools For Visual Studio->Build Tools)
-
CMake (binary, either of the x64 if on Windows)
Check Desktop Development with C++
with these options.
Do NOT check SDK 10.0.19041.0 due to a bug
Check Desktop Development with C++
with these options.
Make sure you have the correct paths to VScode bin, CMake bin, and your compiler's bin (MinGW for example).
In Windows Search bar, type edit the system environment windows -> open it -> Click "Path" and click edit -> add bin paths.
More information in the video below.
-
CMake Tools
-
C/C++
-
CMake
-
CMake Language Support
In the video you will see paths being modified in CMakeLists.txt. Use these in c_cpp_properties.json as well.
Your settings.json
should look like this. Use Visual Studio as your generator; MinGW Makefiles should be a fallback in case if you have it installed.
{
"cmake.configureOnOpen": true,
"cmake.sourceDirectory": "${workspaceFolder}/pilotapp",
"cmake.cmakePath": "C:/CMake/bin/cmake",
"cmake.generator": "Visual Studio 17 2022"
}
For a reference settings.json
, you can visit this gist.