2

I've been doing C++ for a long long time, but I come from the land of Windows.

I've been handed a project that uses CMake. I've googled around trying to learn it.

I run cmake . I assume it always looks for CMakeLists.txt and generates makefiles.

This creates a bunch more cmake files and make files. I was then instructed to run make package. I assume package is just a target name that could be anything.

I then get errors:

c++: error: unrecognized command line option ‘-mthumb-interwork’ c++: error: unrecognized command line option ‘-mfloat-abi=hard’ c++: error: unrecognized command line option ‘-mfpu=neon’ 

I think those are due to the fact that I am trying to compile for a different architecture then the one I am on. I assume all the cmake files would set that up correctly for me. I also assume that nothing there is proprietary.

I see the line in the CMakeLists.txt

SET(CMAKE_CXX_FLAGS "-march=armv7-a -mthumb-interwork -mfloat-abi=hard -mfpu=neon -mtune=cortex-a9 -std=c++11 -O3") 

If I look at the official cmake documentation, it says, and I quote "Flags for all build types." ....Not very helpful

I am thinking it isn't using the correct compiler, but I also don't see where in the CMakeLists.txt the compiler is specified at all.

The question is: Why would these flags be unrecognized?

5
  • 1
    Dear downvoters. Maybe you'd like to specify your reasoning for downvoting a perfectly legitimate question where efforts were described and obviosuly made, such that the poster can form a better question? Otherwise, we'll end up with the exact same thing posted yet again. Commented Jul 18, 2018 at 19:57
  • The question appears to be a run-on. It is not readily apparent what the problem or question is. Commented Jul 18, 2018 at 19:59
  • Ok, edited to be one single black and white question. Commented Jul 18, 2018 at 20:02
  • 3
    The flags are not recognized because you're invoking the wrong compiler. Have you tried make package VERBOSE=1? That should show you the command line calls. You may have to do something like CXX=<path-to-gcc-arm-cross-compiler> cmake <remaining-args> Commented Jul 18, 2018 at 20:19
  • VERBOSE=1 is the bees knees! Commented Jul 18, 2018 at 20:32

1 Answer 1

5

In the Linux world, it's often assumed that you don't need to specify the compiler by name; instead you arrange for c++ to refer to the compiler. That may involve setting PATH, creating a shell alias or a symbolic link.

Apparently you already did so, as your compiler is being called and is complaining about standard GCC flags - clearly your compiler isn't GCC.

The CMakeLists.txt file however is very much assuming it's intended for GCC. Don't blame CMake for that. CMake is the tool, CMakeLists.txt are project-specific instructions. This is a problem of whoever created the particular CMakeLists.txt file.

There's no easy fix. There is a real possibility that the -mfpu=neon option to gcc was necessary for the program, and it's anyone's guess what you'll need on the other compiler.

Sign up to request clarification or add additional context in comments.

1 Comment

Standard makefiles assume that the compiler is specified by the CXX variable - that's the normal way to specify a cross-compiler.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.