2012-04-07 54 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