I am using CMake with QNX Momentics. For that I executed the command
cmake -DCMAKE_TOOLCHAIN_FILE=/my-path/qnx.cmake
on terminal which shown me the below mentioned error:
ERROR:-
"-- The C compiler identification is unknown
CMake Error at CMakeLists.txt:7 (project):
The CMAKE_C_COMPILER:
/home/mobis/MTCI/Test/host/linux/x86_64/usr/bin/ntox86_64-gcc
is not a full path to an existing compiler tool.
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH."
I have checked for
ntox86_64-gcc
compiler in my local pc and it is present at/hom/Test/host/linux/x86_64/usr/bin
location.I have tried to build by giving compiler path at command line with CMake but it shows same error.
Tried below solution even after that same error:
CMAKE_C_COMPILER is not a full path to an existing compiler tool
export CC=/usr/bin/gcc export CXX=/usr/bin/g++
Please find below my qnx.cmake:
set(CMAKE_SYSTEM_NAME QNX)
set(CMAKE_HOST_SYSTEM_NAME QNX)
set(CMAKE_SYSTEM_VERSION 7.0.0)
set(arch ntox86_64)
set(QNX_PROCESSOR x86_64)
SET( TOOLCHAIN QNX )
#Check environment variables
if ("$ENV{QNX_HOST}" STREQUAL "")
message(FATAL_ERROR "QNX_HOST environment variable not set")
endif()
if ("$ENV{QNX_TARGET}" STREQUAL "")
message(FATAL_ERROR "QNX_TARGET environment variable not set")
endif()
set(QNX_HOST "$ENV{QNX_HOST}")
set(QNX_TARGET "$ENV{QNX_TARGET}")
set(CMAKE_C_COMPILER "${QNX_HOST}/usr/bin/${arch}-gcc")
set(CMAKE_CXX_COMPILER "${QNX_HOST}/usr/bin/nto${QCC_NTOARCH}-g++")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_CXX_FLAGS_DEBUG "-g -D_DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set(CMAKE_FIND_ROOT_PATH "${QNX_TARGET}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
Please find below my CMakeLists.txt:
cmake_minimum_required(VERSION 3.14.2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_BUILD_TYPE Release)
project(Test VERSION 1.0 DESCRIPTION "CoreLSP FOlder structure project" LANGUAGES C)
set(SRCS
main.c
printing.c
)
add_executable(Test ${SRCS})
Expected:
- The project should be built successfully and makefile should be produced so that I could import project into QNX Momentics IDE (Linux based Host OS).