New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing CMake options to dependent "existing" module CMake #556

Closed
lws-team opened this Issue Nov 4, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@lws-team
Copy link

lws-team commented Nov 4, 2015

I have a small executable project that has a dependent module that is actually a CMake project of its own.

Yotta does well understanding that it is an "existing" CMake project and building it.

But I need to configure the CMake options of the dependent module from the executable project, I could not find a way to pass -DFEATURE=X type CMake defines into the dependent module.

Does this exist or must the dependent module CMakeLists.txt be hacked... it's a bit yucky when the preexisting library also builds for other platforms using CMake options.

@autopulated

This comment has been minimized.

Copy link
Contributor

autopulated commented Nov 4, 2015

You could put your module inside a directory with its own CMakeLists.txt file, which sets the options and then calls add_subdirectory on the existing module:

modulename
   |_ CMakeLists.txt        # set(...), add_subdirectory(existingmodule)
   \_ existingmodule
         |_ CMakeLists.txt
         |...

Is it a module you would wrap up for other people to use?

When modifying the existing CMakeLists.txt you could guard the defaults you want to set when building for yotta in tests for the version definition for your module that yotta will define:

if(DEFINED YOTTA_<MODULENAME>_VERSION_STRING)
   set(FEATURE=X)
endif()
@lws-team

This comment has been minimized.

Copy link
Author

lws-team commented Nov 4, 2015

Yes it's an existing library targeting other (posixy) platforms already, I'm basically 'adding mbed3 support' to the existing project. https://libwebsockets.org

Your second method sounds good to me, I'll give it a try thanks.

@lws-team lws-team closed this Nov 4, 2015

@autopulated

This comment has been minimized.

Copy link
Contributor

autopulated commented Nov 4, 2015

OK cool – don't hesitate to ask if you have any more qeries!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment