0

I am getting into a problem with the import/export macro called macros.h so I have many includes all in different folders with their own cmakelist in which there are GenerateExportHeader written like this :

string(TOUPPER ${PROJECT_NAME} UPR_PROJECT_NAME)

include (GenerateExportHeader)

GENERATE_EXPORT_HEADER (${PROJECT_NAME}
    BASE_NAME ${UPR_PROJECT_NAME}
    EXPORT_MACRO_NAME ${UPR_PROJECT_NAME}_EXPORT
    EXPORT_FILE_NAME ${PROJECT_NAME}_export.h
    STATIC_DEFINE ${UPR_PROJECT_NAME}_BUILT_AS_STATIC
)

set_property(TARGET utilities APPEND PROPERTY "PRECOMPILE_HEADERS" "$<$<COMPILE_LANGUAGE:CXX>:QtCore>")

i've got 6 of those different export headders, with different export macro names e.g UTILITIES_EXPORT. so in the main cmakelist I have a code part : target_compile_definitions(${can_library} PRIVATE BINDINGS_BUILD) which corresponds with the macros.h, but in my code I have something_export.h includes and SOMETHING_EXPORT macro names and I can't change those.So i need to replace the part with BINDINGS_BUILD to something reffering to all my export headders. I have very few knowledge on this field so my solutin searching can be off. I am open to any quetions or further explaining of my problem

I have tried a build like this :

 #Use the BINDINGS_BUILD definition for the can_library
target_compile_definitions(${can_library} PRIVATE BINDINGS_BUILD)


# Define compile definitions for can_library without BINDINGS_BUILD
set(CAN_LIBRARY_DEFINITIONS
    "BUSINTERFACES_EXPORT"
    "CANBASE_EXPORT"
    "CANOPEN2_EXPORT"
    "SOFTWARE_FRAMEWORK_EXPORT"
    "CANTS_EXPORT"
)

# Check if it's an import build
if (NOT BINDINGS_BUILD)
    set_target_properties(${can_library} PROPERTIES
        COMPILE_DEFINITIONS "${CAN_LIBRARY_DEFINITIONS}"
    )
endif()

but it still errors

this is a similar cmakelists.txt for better understaning (can_library is the same as wiggly) link

0 Answers0