【问题标题】:cmake + sdl - disable sdlmaincmake + sdl - 禁用 sdlmain
【发布时间】:2012-04-08 05:20:29
【问题描述】:

我正在使用 cmake(winxp sp3,cmake 2.8.4)将 SDL 与我的应用程序链接。

cmake_minimum_required(VERSION 2.8)

find_package(SDL REQUIRED)

set(src WIN32 main.cpp)

include_directories(${QT_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${SDL_INCLUDE_DIR})

add_executable(test ${src})

target_link_libraries(test ${SDL_LIBRARY})

问题:SDL_LIBRARY 包含 SDLmain.lib,我需要避免与它链接(我已经有另一个包含 main 但在此 cmakelists.txt 示例中未提及的库)。

我需要从 SDL_LIBRARY 中删除 SDLmain 条目。这必须在不使用库的硬编码路径的情况下完成 - 基本上我需要继续使用 find_package 来设置与 sdl 相关的变量,但我必须确保 SDLmain 不在 SDL_LIBRARY 中。另外,我正在使用没有字符串(查找)的 cmake 2.8.4。

我该怎么做?

【问题讨论】:

    标签: c++ cmake sdl


    【解决方案1】:

    这有帮助吗?

    FindSDL.cmake:

    # This module responds to the the flag:
    # SDL_BUILDING_LIBRARY
    # If this is defined, then no SDL_main will be linked in because 
    # only applications need main().
    # Otherwise, it is assumed you are building an application and this
    # module will attempt to locate and set the the proper link flags
    # as part of the returned SDL_LIBRARY variable.
    

    【讨论】:

    • 嗯...从技术上讲,我不是在构建一个库,但这是可行的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-09
    • 2021-05-21
    • 1970-01-01
    • 1970-01-01
    • 2021-12-25
    相关资源
    最近更新 更多