Gunter, Walter E wrote: > I setup the Main CMakeLists.txt to cross_compile using an arm toolchain: > > cmake_minimum_required(VERSION 3.2) > > project(enterprise CXX) > > set(CMAKE_SYSTEM_NAME Linux) > set(CMAKE_CXX_COMPILER > /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-g++) > set(CMAKE_SYSTEM_PROCESSOR arm) > > set(CMAKE_AR /opt/toolchains/arm-2008q3/bin/arm-none-linux-gnueabi-ar) > set(CMAKE_FIND_ROOT_PATH /mnt/root) > > set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) > set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) > set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) > set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) > > set(COMPILE_FLAGS "-lrt -Wall -lpthread") > > find_package(Threads) > > add_subdirectory(src) > > if(CMAKE_CROSSCOMPILING) > message("I should be cross compiling: ") > endif() > > #find_package(GTest REQUIRED) > > -------------------------------------------------------- > > I made some changes to my cmakelists.txt in my src file : > > set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR} > *list of files*.cpp > Mainfile.cpp > Mycan.cpp #this one references the linux/can.h > ) > > include_directories("../includes") > set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE CXX)
This is not needed, CMake will automatically detect this. > add_executable(enterprise ${SOURCES}) > target_link_libraries(enterprise ${CMAKE_THREAD_LIBS_INIT} pthread) pthread is not needed here. If CMAKE_THREAD_LIBS_INIT is empty you probably have a problem already. Also you should do set(CMAKE_THREAD_PREFER_PTHREAD TRUE) before find_package(Threads), and ideally target_link_libraries(enterprise Threads::Threads) afterwards, as this will also add the -pthread flag to compilation. I still doubt that you properly use a toolchain file (i.e. "cmake -D CMAKE_TOOLCHAIN_FILE=my_arm_stuff.cmake …" in a clean build dir). Eike
signature.asc
Description: This is a digitally signed message part.
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake