2012-04-07 158 views
3

我“米使用cmake(WINXP SP3,cmake的2.8.4)与我的应用程序连接SDL的cmake + SDL - 禁用sdlmain

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,它不会没有字符串(FIND)。

我该怎么做?

回答

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. 
+0

嗯......我不是技术上建立一个图书馆,但这个工程。 – SigTerm 2012-04-07 23:34:23