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

Richard Shaw hobbes1069 at gmail.com
Sat Aug 25 17:48:53 EDT 2018


On Thu, Aug 23, 2018 at 11:58 AM Brad King <brad.king at kitware.com> wrote:

> On 08/22/2018 04:23 PM, Richard Shaw wrote:
>
> Meanwhile you can use just
>
>   set(CMAKE_EXECUTABLE_SUFFIX ".elf")
>

Ok, interestingly that had no effect, but if I moved the
set(CMAKE_EXECUTABLE_SUFFIX_<LANG>) to the main CMakeFiles.txt file below
the project() call it worked.

On Fedora, when I commented out the include for the toolchain file and
applied it on the command line I ran into an issue where it seems like
cmake doesn't understand the source directory as it no longer looked in the
right place for the linker script. In the toolchain file it's set to a
sub-directory of the source dir but it's looking in the binary dir:

set(CMAKE_EXE_LINKER_FLAGS "-T${CMAKE_SOURCE_DIR}/stm32_flash.ld")

Output:
    Linking C executable cmTC_51be3.elf
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_51be3.dir/link.txt
--verbose=1
    /usr/lib64/ccache/arm-none-eabi-gcc  -Wall -std=gnu11 -mlittle-endian
-mthumb -mthumb-interwork -nostartfiles -mcpu=cortex-m4
-fsingle-precision-constant -Wdouble-promotion -mfpu=fpv4-sp-d16
-mfloat-abi=hard -D__FPU_PRESENT=1 -D__FPU_USED=1 --specs=nosys.specs
 -T/home/build/build/stm32/CMakeFiles/CMakeTmp/stm32_flash.ld
CMakeFiles/cmTC_51be3.dir/testCCompiler.c.obj  -o cmTC_51be3.elf
    /usr/lib/gcc/arm-none-eabi/7.1.0/../../../../arm-none-eabi/bin/ld:
cannot open linker script file
/home/build/build/stm32/CMakeFiles/CMakeTmp/stm32_flash.ld: No such file or
directory

The build dir is the binary directory, not the source directory...

Thanks,
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180825/80a6ce5f/attachment.html>


More information about the CMake mailing list