[SOLVED] CMake equivalent of QMake "DEFINES"?



  • Hello,

    Sorry if this may be off topic or if I was tired of googling before asking here :-)

    Qt Creator generated the following code when creating a shared library project:

    @#if defined(APPLETTUTORIAL1_LIBRARY)

    define APPLETTUTORIAL1SHARED_EXPORT Q_DECL_EXPORT

    #else

    define APPLETTUTORIAL1SHARED_EXPORT Q_DECL_IMPORT

    #endif
    @

    In .pro file I had:

    @DEFINES += APPLETTUTORIAL1_LIBRARY@

    What's the equivalent in CMakeLists.txt? I tried this before "add_library..." but it doesn't work:

    @set_property(TARGET applet-tutorial1 PROPERTY APPLETTUTORIAL1_LIBRARY ON)@

    Thank you



  • According to the documentation you can use

    add_definitions(-DAPPLETTUTORIAL1_LIBRARY)
    

    PS: if your TARGET is the library you're building, I guess the set_property must be called only after the add_library statement.



  • Thank you very much, I added this right before the "add_library" statement and it works as expected :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.