From 5e264f8241f7e6e8055def0fc1ae0c6604f18339 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 20 Feb 2015 13:47:38 -0800 Subject: [PATCH] add GLEW as dependency external project --- BUILD_WIN.md | 20 +------------------- cmake/externals/glew/CMakeLists.txt | 26 ++++++++++++++++++++++++++ cmake/modules/FindGLEW.cmake | 15 +++++++++------ interface/CMakeLists.txt | 8 +++----- libraries/gpu/CMakeLists.txt | 8 ++------ libraries/render-utils/CMakeLists.txt | 7 +------ tests/render-utils/CMakeLists.txt | 5 ----- 7 files changed, 42 insertions(+), 47 deletions(-) create mode 100644 cmake/externals/glew/CMakeLists.txt diff --git a/BUILD_WIN.md b/BUILD_WIN.md index f6d484fcd1..6956abbc5f 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -1,9 +1,5 @@ Please read the [general build guide](BUILD.md) for information on dependencies required for all platforms. Only Windows specific instructions are found in this file. -###Windows Specific Dependencies -* [GLEW](http://glew.sourceforge.net/) ~> 1.10.0 -* (remember that you need all other dependencies listed in [BUILD.md](BUILD.md)) - ###Visual Studio 2013 You can use the Community or Professional editions of Visual Studio 2013. @@ -44,18 +40,10 @@ We use CMake's `fixup_bundle` to find the DLLs all of our exectuable targets req The recommended route for CMake to find the external dependencies is to place all of the dependencies in one folder and set one ENV variable - HIFI_LIB_DIR. That ENV variable should point to a directory with the following structure: root_lib_dir - -> glew - -> bin - -> include - -> lib -> openssl -> bin -> include -> lib - -> zlib - -> include - -> lib - -> test For many of the external libraries where precompiled binaries are readily available you should be able to simply copy the extracted folder that you get from the download links provided at the top of the guide. Otherwise you may need to build from source and install the built product to this directory. The `root_lib_dir` in the above example can be wherever you choose on your system - as long as the environment variable HIFI_LIB_DIR is set to it. From here on, whenever you see %HIFI_LIB_DIR% you should substitute the directory that you chose. @@ -79,16 +67,10 @@ To prevent these problems, install OpenSSL yourself. Download the following bina Install OpenSSL into the Windows system directory, to make sure that Qt uses the version that you've just installed, and not some other version. -####GLEW - -Download the binary package: `glew-1.10.0-win32.zip`. Extract to %HIFI_LIB_DIR%\glew (you'll need to rename the default directory name). - -Add to the PATH: `%HIFI_LIB_DIR%\glew\bin\Release\Win32` - ###Build High Fidelity using Visual Studio Follow the same build steps from the CMake section of [BUILD.md](BUILD.md), but pass a different generator to CMake. - cmake .. -DZLIB_LIBRARY=%ZLIB_LIBRARY% -DZLIB_INCLUDE_DIR=%ZLIB_INCLUDE_DIR% -G "Visual Studio 12" + cmake .. -G "Visual Studio 12" Open %HIFI_DIR%\build\hifi.sln and compile. diff --git a/cmake/externals/glew/CMakeLists.txt b/cmake/externals/glew/CMakeLists.txt new file mode 100644 index 0000000000..ca0311cff5 --- /dev/null +++ b/cmake/externals/glew/CMakeLists.txt @@ -0,0 +1,26 @@ +if (WIN32) + set(EXTERNAL_NAME glm) + + include(ExternalProject) + ExternalProject_Add( + ${EXTERNAL_NAME} + URL http://hifi-public.s3.amazonaws.com/dependencies/glew-1.10.0-win32.zip + URL_MD5 37514e4e595a3b3dc587eee8f7e8ec2f + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD 1 + ) + + ExternalProject_Get_Property(${EXTERNAL_NAME} SOURCE_DIR) + + string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) + set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIRS ${SOURCE_DIR}/include CACHE PATH "List of glew include directories") + + set(_LIB_DIR ${SOURCE_DIR}/lib/Release/Win32) + + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${_LIB_DIR}/glew32s.lib CACHE FILEPATH "Location of GLEW release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${_LIB_DIR}/glew32sd.lib CACHE FILEPATH "Location of GLEW debug library") + + set(${EXTERNAL_NAME_UPPER}_DLL_PATH ${SOURCE_DIR}/bin/Release/Win32 CACHE FILEPATH "Location of GLEW DLL") +endif () \ No newline at end of file diff --git a/cmake/modules/FindGLEW.cmake b/cmake/modules/FindGLEW.cmake index 363f346d09..14ea8e52db 100644 --- a/cmake/modules/FindGLEW.cmake +++ b/cmake/modules/FindGLEW.cmake @@ -27,13 +27,16 @@ if (WIN32) find_library(GLEW_LIBRARY_RELEASE glew32s PATH_SUFFIXES "lib/Release/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS}) find_library(GLEW_LIBRARY_DEBUG glew32sd PATH_SUFFIXES "lib/Debug/Win32" "lib" HINTS ${GLEW_SEARCH_DIRS}) + find_path(GLEW_DLL_PATH glew32.dll PATH_SUFFIXES "bin/Release/Win32" HINTS ${GLEW_SEARCH_DIRS}) + include(SelectLibraryConfigurations) select_library_configurations(GLEW) + + set(GLEW_LIBRARIES ${GLEW_LIBRARY}) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES GLEW_DLL_PATH) + + add_paths_to_lib_paths(${GLEW_DLL_PATH}) endif () -set(GLEW_LIBRARIES ${GLEW_LIBRARY}) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIRS GLEW_LIBRARIES) - -mark_as_advanced(GLEW_INCLUDE_DIRS GLEW_LIBRARIES GLEW_SEARCH_DIRS) \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index fb29667e09..446a816d1b 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -219,13 +219,11 @@ else (APPLE) # link target to external libraries if (WIN32) + add_dependency_external_projects(glew) find_package(GLEW REQUIRED) - include_directories(${GLEW_INCLUDE_DIRS}) + target_include_directories(${TARGET_NAME} PRIVATE ${GLEW_INCLUDE_DIRS}) - # we're using static GLEW, so define GLEW_STATIC - add_definitions(-DGLEW_STATIC) - - target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} "${NSIGHT_LIBRARIES}" wsock32.lib opengl32.lib Winmm.lib) + target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} ${NSIGHT_LIBRARIES} wsock32.lib opengl32.lib Winmm.lib) # try to find the Nsight package and add it to the build if we find it find_package(NSIGHT) diff --git a/libraries/gpu/CMakeLists.txt b/libraries/gpu/CMakeLists.txt index 6e7a38f594..7b1d6e743a 100644 --- a/libraries/gpu/CMakeLists.txt +++ b/libraries/gpu/CMakeLists.txt @@ -11,15 +11,11 @@ if (APPLE) target_link_libraries(${TARGET_NAME} ${OpenGL}) elseif (WIN32) + add_dependency_external_projects(glew) find_package(GLEW REQUIRED) - include_directories(${GLEW_INCLUDE_DIRS}) - - # we're using static GLEW, so define GLEW_STATIC - add_definitions(-DGLEW_STATIC) + target_include_directories(${TARGET_NAME} PUBLIC ${GLEW_INCLUDE_DIRS}) target_link_libraries(${TARGET_NAME} ${GLEW_LIBRARIES} opengl32.lib) - - target_include_directories(${TARGET_NAME} PUBLIC ${GLEW_INCLUDE_DIRS}) # try to find the Nsight package and add it to the build if we find it find_package(NSIGHT) diff --git a/libraries/render-utils/CMakeLists.txt b/libraries/render-utils/CMakeLists.txt index b266c001e4..9a08b8c7ed 100644 --- a/libraries/render-utils/CMakeLists.txt +++ b/libraries/render-utils/CMakeLists.txt @@ -12,9 +12,4 @@ add_dependency_external_projects(glm) find_package(GLM REQUIRED) target_include_directories(${TARGET_NAME} PUBLIC ${GLM_INCLUDE_DIRS}) -link_hifi_libraries(animation fbx shared gpu) - -if (WIN32) - # we're using static GLEW, so define GLEW_STATIC - add_definitions(-DGLEW_STATIC) -endif () +link_hifi_libraries(animation fbx shared gpu) \ No newline at end of file diff --git a/tests/render-utils/CMakeLists.txt b/tests/render-utils/CMakeLists.txt index d55d3c542b..0452fd629c 100644 --- a/tests/render-utils/CMakeLists.txt +++ b/tests/render-utils/CMakeLists.txt @@ -7,9 +7,4 @@ setup_hifi_project(Quick Gui OpenGL) # link in the shared libraries link_hifi_libraries(render-utils gpu shared) -if (WIN32) - # we're using static GLEW, so define GLEW_STATIC - add_definitions(-DGLEW_STATIC) -endif () - copy_dlls_beside_windows_executable() \ No newline at end of file