[CMake] Find parent of ${PROJECT_SOURCE_DIR}

2018-08-27 Thread Ke Gao
Hi, I tried different way of using GET_FILENAME_COMPONENT to find the parent path of PROJECT_SOURCE_DIR, or another path relative to the parent of PROJECT_SOURCE_DIR, never succeeded. Can anybody help, thank you very much. None of the following works. I'm using Cmake 2.8.12 GET_FILENAME_COMPONEN

Re: [CMake] Build flags not applied during compiler testing on Ubuntu

2018-08-27 Thread Brad King
On 08/25/2018 05:48 PM, Richard Shaw wrote: > set(CMAKE_EXE_LINKER_FLAGS "-T${CMAKE_SOURCE_DIR}/stm32_flash.ld") > > The build dir is the binary directory, not the source directory... Toolchain files cannot reference variables like CMAKE_SOURCE_DIR that depend on the source and build tree locatio

Re: [CMake] CMake specify using either NVCC or host compilers with add_executable

2018-08-27 Thread Petr Kmoch
Hi Quang, I believe this should be doable with setting the source file's LANGUAGE property ( https://cmake.org/cmake/help/latest/prop_sf/LANGUAGE.html ): add_executable(foo_cuda foo.cpp) set_property(SOURCE foo.cpp PROPERTY LANGUAGE CUDA) Petr On Mon, 27 Aug 2018 at 17:40, Quang Ha wrote: > H

[CMake] CMake specify using either NVCC or host compilers with add_executable

2018-08-27 Thread Quang Ha
Hi all, With the new way CMake is treating CUDA codes, now we can do: project(foo LANGUAGES CXX CUDA) and can do: add_executable(foo_cuda foo.cu) # will use NVCC add_executable(foo_cpp foo.cpp) # will use host compilers Now since CUDA can take *.cpp files as extension (see https://stackoverflo