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

2018-08-30 Thread Richard Shaw
On Mon, Aug 27, 2018 at 12:43 PM Brad King  wrote:

> 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 locations.  They are loaded
> inside try_compile projects in addition to the main project, and those
> have their own source and build trees.
>

Ok, fixed but it's really a PITA to have to type -DCMAKE_TOOLCHAIN_FILE=..
so often when 100% of the people on this project are cross-compiling.

And I'm still being bit by differences between Fedora and Ubuntu...

Compiling is working fine again on Fedora but on Ubuntu it's failing to
find the STM32 library. I quite clearly specify its in the BINARY directory
but on Ubuntu it's still looking for it in the SOURCE directory...

set(PERIPHLIBVER1.8.0)
set(PERIPHLIBNAME   STM32F4xx_DSP_StdPeriph_Lib_V)
set(PERIPHLIBDIR${CMAKE_BINARY_DIR}/${PERIPHLIBNAME}${PERIPHLIBVER})
set(CMSIS   ${PERIPHLIBDIR}/Libraries/CMSIS)
set(STM32F4LIB  ${PERIPHLIBDIR}/Libraries/STM32F4xx_StdPeriph_Driver)
set(STM32F4TEMPLATE ${PERIPHLIBDIR}/Project/STM32F4xx_StdPeriph_Templates)
set(DSPLIB  ${PERIPHLIBDIR}/Libraries/CMSIS/DSP_Lib)

Output on Ubuntu:

 cmake -DCMAKE_TOOLCHAIN_FILE=STM32_Toolchain.cmake
~/svn/freetel/codec2-dev/stm32/-- Configuring done
CMake Error at CMakeLists.txt:134 (add_executable):
  Cannot find source file:


/home/richard/svn/freetel/codec2-dev/stm32/STM32F4xx_DSP_StdPeriph_Lib_V1.8.0/Libraries/CMSIS/DSP_Lib/Examples/arm_fft_bin_example/GCC/arm_fft_bin_data.c

Thanks,
Richard
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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 locations.  They are loaded
inside try_compile projects in addition to the main project, and those
have their own source and build trees.

-Brad
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2018-08-25 Thread Richard Shaw
On Thu, Aug 23, 2018 at 11:58 AM Brad King  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_) 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
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2018-08-23 Thread Brad King
On 08/22/2018 04:23 PM, Richard Shaw wrote:
> Here's the contents:
>
> set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
> set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
> set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")
[snip]
On 08/22/2018 05:05 PM, Richard Shaw wrote:
> One step closer:
> ...me forcing the binary output to have a .elf extension is confusing cmake:
>
> Unable to find the executable at any of:
>   /home/richard/build/stm32/CMakeFiles/CMakeTmp/cmTC_64527
>   /home/richard/build/stm32/CMakeFiles/CMakeTmp/Debug/cmTC_64527
>   /home/richard/build/stm32/CMakeFiles/CMakeTmp/Development/cmTC_64527

Ah, that's a bug.  I've just opened this issue:

  https://gitlab.kitware.com/cmake/cmake/issues/18288

Meanwhile you can use just

  set(CMAKE_EXECUTABLE_SUFFIX ".elf")

instead.

-Brad
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2018-08-22 Thread Brad King
On 08/22/2018 04:23 PM, Richard Shaw wrote:
> Currently I'm using an "include" of the toolchain file prior to calling
> "project" since 100% of development happens on a PC instead of having
> to pass the CMAKE_TOOLCHAIN_FILE option every time.

CMAKE_TOOLCHAIN_FILE must be used in order to be properly included
by try_compile projects and such.  One can't just include() it
manually.

> Here's the contents:
> 
> set(CMAKE_SYSTEM_NAME Generic)
> set(CMAKE_SYSTEM_PROCESSOR arm)
> set(CMAKE_SYSTEM_VERSION 1)
> 
> # specify the cross compiler
> set(CMAKE_C_COMPILER arm-none-eabi-gcc)
> set(CMAKE_CXX_COMPILER arm-none-eabi-cpp)

Add

```
set(CMAKE_C_FLAGS_INIT "--specs=nosys.specs")
set(CMAKE_CXX_FLAGS_INIT "--specs=nosys.specs")
```

and be sure to use CMake 3.7 or higher.

-Brad
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2018-08-22 Thread Richard Shaw
On Wed, Aug 22, 2018 at 3:02 PM Brad King  wrote:

> On 08/22/2018 03:49 PM, Richard Shaw wrote:
> > Initially I tried setting the flags before invoking "project" and that
> seemed
> > to be enough for Fedora. I've tried other things as well that I've
> probably
> > forgotten but one other method I tried was:
> >
> > set(CMAKE_REQUIRED_DEFINITIONS "--specs=nosys.specs")
>
> That's only used by Check* modules.  It does not affect flags in general.
>

Good to know, I can remove that.



> From the ubuntu issue:
>
> > The target system is: Generic - 1 - arm
> > The host system is: Linux - 4.15.0-32-generic - x86_64
>
> You're cross-compiling.  What is your CMAKE_TOOLCHAIN_FILE?
>

Yes, I could have worded it better but I have tried passing the toolchain
file on the command line with the same result. Currently I'm using an
"include" of the toolchain file prior to calling "project" since 100% of
development happens on a PC instead of having to pass the
CMAKE_TOOLCHAIN_FILE option every time.

Here's the contents:

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_SYSTEM_VERSION 1)


# specify the cross compiler
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-cpp)

set(CMAKE_EXE_LINKER_FLAGS "-T${CMAKE_SOURCE_DIR}/stm32_flash.ld")
set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")

# Macro for elf->bin
macro(elf2bin target)
add_custom_command(TARGET ${target}
POST_BUILD COMMAND ${CMAKE_OBJCOPY} -O binary ${target}.elf
${target}.bin
COMMENT "Creating binary for ${target}")
endmacro()

Thanks,
Richard
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2018-08-22 Thread Brad King
On 08/22/2018 03:49 PM, Richard Shaw wrote:
> Initially I tried setting the flags before invoking "project" and that seemed
> to be enough for Fedora. I've tried other things as well that I've probably
> forgotten but one other method I tried was:
> 
> set(CMAKE_REQUIRED_DEFINITIONS "--specs=nosys.specs")

That's only used by Check* modules.  It does not affect flags in general.

>From the ubuntu issue:

> The target system is: Generic - 1 - arm
> The host system is: Linux - 4.15.0-32-generic - x86_64

You're cross-compiling.  What is your CMAKE_TOOLCHAIN_FILE?

-Brad
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2018-08-22 Thread Richard Shaw
On Wed, Aug 22, 2018 at 1:51 PM Brad King  wrote:

> On 08/21/2018 03:18 PM, Richard Shaw wrote:
> > without --specs=nosys.specs applied during compiler testing, cmake fails.
>
> How is this flag specified when invoking CMake?
>

Initially I tried setting the flags before invoking "project" and that
seemed to be enough for Fedora. I've tried other things as well that I've
probably forgotten but one other method I tried was:

set(CMAKE_REQUIRED_DEFINITIONS "--specs=nosys.specs")

but nothing seems to work. I even tried passiting the toolchain option on
the command line with the same result.



> > https://bugs.launchpad.net/ubuntu/+source/cmake/+bug/1787723
>
> According to that discussion it works on Fedora but not on Ubuntu.
> Please try an upstream version of CMake to compare behavior.


I'll see what I can do but I'm not very Ubuntu knowledgeable. I try
download the linux binary gz file from cmake.org.

Thanks,
Richard
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2018-08-22 Thread Brad King
On 08/21/2018 03:18 PM, Richard Shaw wrote:
> without --specs=nosys.specs applied during compiler testing, cmake fails.

How is this flag specified when invoking CMake?

> https://bugs.launchpad.net/ubuntu/+source/cmake/+bug/1787723

According to that discussion it works on Fedora but not on Ubuntu.
Please try an upstream version of CMake to compare behavior.

-Brad
-- 

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:
https://cmake.org/mailman/listinfo/cmake


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

2018-08-21 Thread Richard Shaw
I have a cross platform project that I have building correctly for the
STM32 platform on Fedora but everyone using Ubuntu is having problems.

Basically, without --specs=nosys.specs applied during compiler testing,
cmake fails. I have reports of this happening on Ubuntu 14.x, 16,x and have
setup a virtual machine for 18.x.

The gory details are here:

https://bugs.launchpad.net/bugs/1787723

For the meantime, is there a way I can force cmake to apply the flags?

Thanks,
Richard
-- 

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:
https://cmake.org/mailman/listinfo/cmake