From 7632a5abd47e4a228291d18a5f9ebef8a1ca38f6 Mon Sep 17 00:00:00 2001 From: Christian Morales Vega Date: Thu, 18 Nov 2010 23:27:27 +0000 Subject: [PATCH] Fix for issue 3507. Compile with old GLEW versions, support user-specified CFLAGS and link plugins to all the used libs. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6441 8ced0084-cf51-0410-be5f-012b33b47a6e --- CMakeLists.txt | 32 +++++++++---------- CMakeTests/CheckLib.cmake | 15 +++++++++ Externals/CLRun/CMakeLists.txt | 1 + Source/Plugins/Plugin_DSP_HLE/CMakeLists.txt | 8 +++-- Source/Plugins/Plugin_DSP_LLE/CMakeLists.txt | 4 +-- Source/Plugins/Plugin_VideoOGL/CMakeLists.txt | 7 ++-- .../Plugin_VideoSoftware/CMakeLists.txt | 4 ++- 7 files changed, 47 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1d5c5111d..c326251ace 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,7 @@ endif(NO_UNUSED_RESULT) CHECK_CXX_COMPILER_FLAG(-fvisibility-inlines-hidden VISIBILITY_INLINES_HIDDEN) if(VISIBILITY_INLINES_HIDDEN) - set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden") endif(VISIBILITY_INLINES_HIDDEN) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") @@ -242,16 +242,17 @@ include_directories(Externals/Bochs_disasm) add_subdirectory(Externals/Lua) include_directories(Externals/Lua) -find_library(LZO lzo2) -find_path(LZO_INCLUDE lzo/lzo1x.h) -if(LZO AND LZO_INCLUDE) +include(CheckLib) + +check_lib_and_header(LZO lzo2 lzo/lzo1x.h OPTIONAL) +if(LZO_FOUND) message("Using shared lzo") include_directories(${LZO_INCLUDE}) else() message("Shared lzo not found, falling back to the static library") add_subdirectory(Externals/LZO) include_directories(Externals/LZO) -endif(LZO AND LZO_INCLUDE) +endif() include(FindSDL OPTIONAL) if(SDL_FOUND) @@ -264,27 +265,25 @@ else(SDL_FOUND) add_subdirectory(Externals/SDL) endif(SDL_FOUND) -find_library(SFML_NETWORK sfml-network) -find_path(SFML_INCLUDE SFML/Network/Ftp.hpp) -if(SFML_NETWORK AND SFML_INCLUDE) +check_lib_and_header(SFML sfml-network SFML/Network/Ftp.hpp OPTIONAL) +if(SFML_FOUND) message("Using shared sfml-network") include_directories(${SFML_INCLUDE}) else() message("Shared sfml-network not found, falling back to the static library") add_subdirectory(Externals/SFML) include_directories(Externals/SFML/include) -endif(SFML_NETWORK AND SFML_INCLUDE) +endif() -find_library(SOIL SOIL) -find_path(SOIL_INCLUDE SOIL/SOIL.h) -if(SOIL AND SOIL_INCLUDE) +check_lib_and_header(SOIL SOIL SOIL/SOIL.h OPTIONAL) +if(SOIL_FOUND) message("Using shared SOIL") include_directories(${SOIL_INCLUDE}) else() message("Shared SOIL not found, falling back to the static library") add_subdirectory(Externals/SOIL) include_directories(Externals/SOIL) -endif(SOIL AND SOIL_INCLUDE) +endif() include(FindZLIB OPTIONAL) if(ZLIB_FOUND) @@ -300,11 +299,10 @@ if(WIN32) find_library(GLEW glew32s PATHS Externals/GLew) include_directories(Externals/GLew/include) else() - include(CheckLib) - check_lib(GLEW glew REQUIRED) check_lib(GLU glu REQUIRED) - check_lib(CG Cg REQUIRED) - check_lib(CGGL CgGL REQUIRED) + check_lib_and_header(GLEW GLEW GL/glew.h REQUIRED) + check_lib_and_header(CG Cg Cg/cg.h REQUIRED) + check_lib_and_header(CGGL CgGL Cg/cgGL.h REQUIRED) endif() if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) diff --git a/CMakeTests/CheckLib.cmake b/CMakeTests/CheckLib.cmake index 5287113993..ad068421b3 100644 --- a/CMakeTests/CheckLib.cmake +++ b/CMakeTests/CheckLib.cmake @@ -17,3 +17,18 @@ macro(check_lib var lib required) endif() endmacro() +macro(check_lib_and_header var lib header required) + find_library(${var} ${lib}) + find_path(${var}_INCLUDE ${header}) + if(${var} AND ${var}_INCLUDE) + message("${lib} found") + set(${var}_FOUND 1 CACHE INTERNAL "") + else() + if(${required} STREQUAL "REQUIRED") + message(FATAL_ERROR "${lib} is required but not found") + else() + message("${lib} not found") + endif() + endif() +endmacro() + diff --git a/Externals/CLRun/CMakeLists.txt b/Externals/CLRun/CMakeLists.txt index 0a5ee41427..78161bc10a 100644 --- a/Externals/CLRun/CMakeLists.txt +++ b/Externals/CLRun/CMakeLists.txt @@ -6,4 +6,5 @@ set(SRCS clrun/clrun.c add_library(clrun STATIC ${SRCS}) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") add_definitions(-fPIC) + target_link_libraries(clrun ${CMAKE_DL_LIBS}) endif() diff --git a/Source/Plugins/Plugin_DSP_HLE/CMakeLists.txt b/Source/Plugins/Plugin_DSP_HLE/CMakeLists.txt index 5c6e36a0fb..3ff95fb249 100644 --- a/Source/Plugins/Plugin_DSP_HLE/CMakeLists.txt +++ b/Source/Plugins/Plugin_DSP_HLE/CMakeLists.txt @@ -20,8 +20,12 @@ if(wxWidgets_FOUND) set(SRCS ${SRCS} Src/ConfigDlg.cpp) endif(wxWidgets_FOUND) -add_library(Plugin_DSP_HLE SHARED ${SRCS}) -target_link_libraries(Plugin_DSP_HLE common audiocommon) +add_library(Plugin_DSP_HLE MODULE ${SRCS}) +if(wxWidgets_FOUND) + target_link_libraries(Plugin_DSP_HLE common audiocommon ${wxWidgets_LIBRARIES}) +else(wxWidgets_FOUND) + target_link_libraries(Plugin_DSP_HLE common audiocommon) +endif(wxWidgets_FOUND) install(TARGETS Plugin_DSP_HLE LIBRARY DESTINATION ${plugindir} RUNTIME DESTINATION ${plugindir}) diff --git a/Source/Plugins/Plugin_DSP_LLE/CMakeLists.txt b/Source/Plugins/Plugin_DSP_LLE/CMakeLists.txt index aa2843020a..f646cdd543 100644 --- a/Source/Plugins/Plugin_DSP_LLE/CMakeLists.txt +++ b/Source/Plugins/Plugin_DSP_LLE/CMakeLists.txt @@ -15,10 +15,10 @@ if(wxWidgets_FOUND) Src/DSPConfigDlgLLE.cpp Src/Debugger/DSPDebugWindow.cpp Src/Debugger/DSPRegisterView.cpp) - set(LIBS ${LIBS} debugger_ui_util) + set(LIBS ${LIBS} debugger_ui_util ${wxWidgets_LIBRARIES}) endif(wxWidgets_FOUND) -add_library(Plugin_DSP_LLE SHARED ${SRCS}) +add_library(Plugin_DSP_LLE MODULE ${SRCS}) target_link_libraries(Plugin_DSP_LLE ${LIBS}) install(TARGETS Plugin_DSP_LLE LIBRARY DESTINATION ${plugindir} diff --git a/Source/Plugins/Plugin_VideoOGL/CMakeLists.txt b/Source/Plugins/Plugin_VideoOGL/CMakeLists.txt index f82d0eb1fc..60a585534c 100644 --- a/Source/Plugins/Plugin_VideoOGL/CMakeLists.txt +++ b/Source/Plugins/Plugin_VideoOGL/CMakeLists.txt @@ -16,12 +16,15 @@ set(LIBS videocommon SOIL common Cg - CgGL) + CgGL + ${OPENGL_LIBRARIES} + ${X11_LIBRARIES}) if(wxWidgets_FOUND) set(SRCS ${SRCS} Src/Debugger/Debugger.cpp) set(LIBS videouicommon ${LIBS}) + set(LIBS ${LIBS} ${wxWidgets_LIBRARIES}) endif(wxWidgets_FOUND) if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND NOT wxWidgets_FOUND) @@ -32,7 +35,7 @@ elseif(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) set(LIBS ${LIBS} clrun) endif() -add_library(Plugin_VideoOGL SHARED ${SRCS}) +add_library(Plugin_VideoOGL MODULE ${SRCS}) target_link_libraries(Plugin_VideoOGL ${LIBS}) install(TARGETS Plugin_VideoOGL LIBRARY DESTINATION ${plugindir} diff --git a/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt b/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt index 9f213f0c8b..17de58c67b 100644 --- a/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt +++ b/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt @@ -27,7 +27,9 @@ set(SRCS Src/BPMemLoader.cpp set(LIBS videocommon GLEW SOIL - common) + common + ${OPENGL_LIBRARIES} + ${X11_LIBRARIES}) if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND NOT wxWidgets_FOUND) set(SRCS ${SRCS} Src/cocoaGL.m)