Skip to content
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

Inject macros via cmake #2633

Open
Piankero opened this Issue Apr 14, 2019 · 7 comments

Comments

Projects
None yet
3 participants
@Piankero
Copy link
Contributor

Piankero commented Apr 14, 2019

I need help concerning injecting a macro into all files for the libs.

I pushed my current code into my fork branch. The last commit there shows my approach.

For every plugin it works and ELEKTRA_MODULE_NAME gets correctly replaced.
The libs modules though do not. If you run ctest -R test_opts you can see that nothing changes (ignore the test errors, they are not fixed yet).

Does anybody has experience with that? I seriously do not know what else I could do.

@Piankero

This comment has been minimized.

Copy link
Contributor Author

Piankero commented Apr 22, 2019

@petermax2 : Can you help me why this is not working yet? You achieved this for all plugins

@petermax2

This comment has been minimized.

Copy link
Member

petermax2 commented Apr 22, 2019

Hm, it's just a guess but have you tried to set COMPILE_DEFINITIONS before the first invocation of target_link_libraries?

Before this block:

if (BUILD_SHARED)
add_library (elektra-${name} SHARED ${ARG_SOURCES})
add_dependencies (elektra-${name} kdberrors_generated elektra_error_codes_generated ${ARG_LINK_ELEKTRA})
target_link_libraries (elektra-${name} elektra-core ${ARG_LINK_ELEKTRA})
endif (BUILD_SHARED)

Otherwise you have been taking over the pattern I have used to accomplish the propagation of ELEKTRA_PLUGIN_NAME and ELEKTRA_PLUGIN_NAME_C symbols.

@Piankero

This comment has been minimized.

Copy link
Contributor Author

Piankero commented Apr 22, 2019

I tried this in 75d7f1b without any success unfortunately :/

@petermax2

This comment has been minimized.

Copy link
Member

petermax2 commented Apr 22, 2019

I'm confused too. Maybe add_plugin messes up the setup of add_lib in some way, but I'm not sure. I've tried several things on your branch but without success.

@Piankero

This comment has been minimized.

Copy link
Contributor Author

Piankero commented Apr 22, 2019

Thank you very much @petermax2 for your help!
@markus2330 : Maybe we add the macro in every lib now separately? Or do you have another idea?

@petermax2

This comment has been minimized.

Copy link
Member

petermax2 commented Apr 22, 2019

The properties seem to be set properly from within CMake. If I add the following debugging code:

index 658b5b783..a24f54303 100644
--- a/cmake/Modules/LibAddLib.cmake
+++ b/cmake/Modules/LibAddLib.cmake
@@ -37,14 +37,16 @@ function (add_lib name)
                      PROPERTY "elektra-extension_LIBRARIES"
                               elektra-${name})
 
-       set_additional_compile_definitions(${name})
-
+       set_additional_lib_compile_definitions(${name})
        set_property (TARGET elektra-${name}
                APPEND
                PROPERTY COMPILE_DEFINITIONS
-                       ${ADDITIONAL_COMPILE_DEFINITIONS}
+                       ${ADDITIONAL_LIB_COMPILE_DEFINITIONS}
 )
 
+       get_property(LIB_PROPS TARGET elektra-${name} PROPERTY COMPILE_DEFINITIONS)
+       message(STATUS "===============> elektra-${name} COMPILE_DEFINITIONS=${LIB_PROPS}")
+
        if (BUILD_SHARED)
                target_link_libraries (elektra-${name} ${ARG_LINK_LIBRARIES})

I get the following (seemingly correct) CMake output:

-- ===============> elektra-ease COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=ease
-- ===============> elektra-globbing COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=globbing
-- ===============> elektra-proposal COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=proposal
-- ===============> elektra-meta COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=meta
-- ===============> elektra-plugin COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=plugin
-- ===============> elektra-pluginprocess COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=pluginprocess
-- ===============> elektra-utility COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=utility
-- ===============> elektra-io COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=io
-- ===============> elektra-invoke COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=invoke
-- ===============> elektra-notification COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=notification
-- ===============> elektra-highlevel COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=highlevel
-- ===============> elektra-opts COMPILE_DEFINITIONS=ELEKTRA_MODULE_NAME=opts

I don't know why ELEKTRA_MODULE_NAME is not available in opts.c.

@markus2330

This comment has been minimized.

Copy link
Contributor

markus2330 commented Apr 22, 2019

@kodebach do you have an idea here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.