Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

cmake drops build settings when descending into submodules - compiler checks fail #73

Closed
challinan opened this issue Dec 15, 2016 · 5 comments
Assignees
Labels

Comments

@challinan
Copy link

challinan commented Dec 15, 2016

I have prototyped a build script modeled after Intel Edison build script and it's corresponding environment setup script from Intel Edison toolchain. When my build script starts, it sets up the environment, and calls cmake on build_root, the top level CMakeLists.txt performs the compiler checks and they pass.

-- Check for working C compiler: /home/chris/mgc-cedar-minnowmax/embedded/codebench/bin/i686-pc-linux-gnu-gcc -- works

But as soon as the build system descends into any submodule, these checks fail: (some debug messages() have been added)

-- CMAKE_SOURCE_DIR: /scratch/sandbox/azure-iot-gateway-sdk/deps/ctest
-- Check for working C compiler: /home/chris/mgc-cedar-minnowmax/embedded/codebench/bin/i686-pc-linux-gnu-gcc -- broken

Upon further inspection, the variables that were set in the toolchain_file passed to cmake (using cmake's SET() directive) are blank, ie they have not been propagated into the submodule. Therefore, all my CFLAGS and LDFLAGS are effectively null, and the compiler check naturally fails.

What I know about cmake could fill a paragraph, and not more (well, actually I'm learning way more than I ever wanted to about cmake LOL!)

Where am I going wrong?
Note that I faced a similar failed compiler check running the Intel Edison example using the stock Edison toolchain and corresponding build script. I documented that in #71

@darobs
Copy link
Contributor

darobs commented Jan 11, 2017

Hello @challinan, our own Intel Edison and Wind River Linux cross-compiles are interesting. They really weren't taking advantage of CMake's toolchain capability - they were setting up the environment to use the native build tools and set the target sysroot. It works for the specific toolchains we have, but we ran into similar problems on other platforms.

One interesting thing to note: CMake doesn't populate its own variables until after the project statement, and your cross-compile is failing in the "project" statement. This, if I may say so myself, is very frustrating.

I can definitely confirm one problem: When we build our submodule dependencies, we're not sending the toolchain option. I should have a new commit coming soon which address this.

@challinan
Copy link
Author

I believe it is the submodule problem we are seeing. At one point, I was "guessing" that cmake was actually either dropping or changing our toolchain variables. This would certainly explain that behavior. Thanks for looking at this.

@darobs
Copy link
Contributor

darobs commented Jan 11, 2017

This has been pushed into the develop branch. I'll be curious to see if this change helps you.

@damonbarry
Copy link
Member

899eb5b

@damonbarry
Copy link
Member

Fix is in master

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants