WIP Static libraries on windows

This commit is contained in:
DawidPietrykowski 2023-06-05 00:21:47 +02:00
parent 133701c417
commit d84a7a93da
2 changed files with 33 additions and 18 deletions

View File

@ -83,14 +83,23 @@ set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
#message(FATAL_ERROR "glfw3.lib not found")
#endif()
find_package(glfw3 REQUIRED)
find_package(glfw3 CONFIG REQUIRED)
# Find GLEW
# unset (GLEW_USE_STATIC_LIBS CACHE)
# unset (GLEW_LIBRARIES CACHE)
# set(GLEW_USE_STATIC_LIBS TRUE)
# set(GLEW_VERBOSE TRUE)
# SET(GLEW_DIR "C:\\Desktop\\git\\vcpkg\\downloads\\tools\\cmake-3.25.1-windows\\cmake-3.25.1-windows-i386\\share\\cmake-3.25\\Modules")
set(VCPKG_TARGET_TRIPLET x64-windows-static)
find_package(GLEW REQUIRED)
set(VCPKG_TARGET_TRIPLET x64-windows)
if(GLEW_FOUND)
set(GLEW_INCLUDE_DIR ${GLEW_INCLUDE_DIRS})
get_filename_component(GLEW_LIBRARIES ${GLEW_LIBRARIES} DIRECTORY)
#get_filename_component(GLEW_LIBRARIES ${GLEW_LIBRARIES} DIRECTORY)
message(STATUS "GLEW_INCLUDE_DIR: ${GLEW_INCLUDE_DIR}")
message(STATUS "GLEW_LIBRARIES: ${GLEW_LIBRARIES}")
else()
@ -103,17 +112,20 @@ if(NOT WIN32)
endif()
# Find stb_image
find_path(stb_image_INCLUDE_DIR stb_image.h
HINTS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/stb
${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_CURRENT_SOURCE_DIR}
"/usr/include/stb"
${stb_image_ROOT})
if(stb_image_INCLUDE_DIR)
message(STATUS "stb_image_INCLUDE_DIR: ${stb_image_INCLUDE_DIR}")
find_package(Stb REQUIRED)
#find_path(stb_image_INCLUDE_DIR stb_image.h
# HINTS
# ${CMAKE_CURRENT_SOURCE_DIR}/include
# ${CMAKE_CURRENT_SOURCE_DIR}/include/stb
# ${CMAKE_CURRENT_SOURCE_DIR}/lib
# ${CMAKE_CURRENT_SOURCE_DIR}
# "/usr/include/stb"
# ${stb_image_ROOT})
if(Stb_INCLUDE_DIR)
message(STATUS "Stb_INCLUDE_DIR: ${Stb_INCLUDE_DIR}")
else()
message(FATAL_ERROR "stb_image not found")
endif()
@ -123,10 +135,15 @@ add_subdirectory(src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src
${GLFW_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${stb_image_INCLUDE_DIR}
${Stb_INCLUDE_DIR}
${GLEW_INCLUDE_DIR})
target_link_directories(${PROJECT_NAME} PUBLIC ${GLFW_LIB_DIR} ${GLEW_LIBRARIES})
target_link_libraries(${PROJECT_NAME} glfw OpenGL::GL GLEW::GLEW)
if(WIN32)
target_link_libraries(${PROJECT_NAME} glfw GLEW::glew_s)
else()
target_link_libraries(${PROJECT_NAME} glfw OpenGL::GL GLEW::glew_s)
endif()
# Header files

View File

@ -1,8 +1,6 @@
@echo off
set GLFW_ROOT=
set GLEW_ROOT=
set stb_image_ROOT=
set vcpkg_ROOT=C:\Desktop\git\vcpkg\scripts\buildsystems\vcpkg.cmake
cmake -B build -S . -DGLFW_ROOT=%GLFW_ROOT% -DGLEW_ROOT=%GLEW_ROOT% -Dstb_image_ROOT=%stb_image_ROOT%
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=%vcpkg_ROOT% -DGLEW_VERBOSE=TRUE -DGLEW_USE_STATIC_LIBS=ON -DVCPKG_TARGET_TRIPLET=x64-windows-static
cmake --build build --config Release