mercredi 6 mai 2015

Output the DLL instead of .exe with cmake/mingw

I'm not very familiar with both cmake and mingw.

I have some source code that can be build with it (and the build process works fine with mingw32-make). The problem is, I would like to output the DLLs and not the .exe files.

I have some CMakeList file that I believe stores the configuration I have to change (that part should be responsible to produce the .exe files for .cpp files in Examples/ directory, taking some dependencies into account):

# C examples
if(PSMOVE_BUILD_EXAMPLES)
    foreach(EXAMPLE example multiple dump_calibration battery_check)
        add_executable(${EXAMPLE} examples/c/${EXAMPLE}.c)
        target_link_libraries(${EXAMPLE} psmoveapi)
    endforeach()

    if(PSMOVE_BUILD_TRACKER AND PSMOVE_BUILD_TUIO_SERVER)
        include_directories(${PSMOVEAPI_SOURCE_DIR}/external/TUIO_CPP/TUIO)
        include_directories(${PSMOVEAPI_SOURCE_DIR}/external/TUIO_CPP/oscpack)
        add_executable(tuio_server examples/c/tuio_server.cpp
            external/TUIO_CPP/TUIO/TuioClient.cpp
...
            external/TUIO_CPP/oscpack/ip/win32/NetworkingUtils.cpp
            external/TUIO_CPP/oscpack/ip/win32/UdpSocket.cpp)
        set_target_properties(tuio_server PROPERTIES
            COMPILE_FLAGS -DOSC_HOST_LITTLE_ENDIAN)
        target_link_libraries(tuio_server psmoveapi psmoveapi_tracker)
    else()
        # Disable the TUIO Server if we don't build the tracker
        set(PSMOVE_BUILD_TUIO_SERVER OFF)
    endif()

    if(PSMOVE_BUILD_TRACKER)
        foreach(EXAMPLE distance_calibration)
            add_executable(${EXAMPLE} examples/c/${EXAMPLE}.c)
            target_link_libraries(${EXAMPLE} psmoveapi psmoveapi_tracker)
        endforeach()
    endif()
endif()

I guess I should add -DBUILDING_EXAMPLE_DLL and -shared options somewhere. But where exactly? Or maybe I'm missing the point?

Aucun commentaire:

Enregistrer un commentaire