Skip to content

Commit

Permalink
Merge pull request #789 from myd7349/fix-cmake-for-win32
Browse files Browse the repository at this point in the history
Fix CMake support on Win32
  • Loading branch information
raysan5 authored Apr 22, 2019
2 parents cd934c9 + 148eefb commit e41cb77
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if (ENABLE_MSAN AND ENABLE_ASAN)
MESSAGE(WARNING "Compiling with both AddressSanitizer and MemorySanitizer is not recommended")
endif()

add_subdirectory(src release)
add_subdirectory(src)

if (${BUILD_EXAMPLES})
add_subdirectory(examples)
Expand Down
19 changes: 13 additions & 6 deletions cmake/raylib-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,26 @@ if (raylib_USE_STATIC_LIBS)
set(XPREFIX ${XPREFIX}_STATIC)
endif()

find_package(PkgConfig)
pkg_check_modules(${XPREFIX} REQUIRED raylib)
find_package(PkgConfig QUIET)
pkg_check_modules(${XPREFIX} QUIET raylib)
set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS})

find_path(raylib_INCLUDE_DIR
NAMES raylib.h
HINTS ${${XPREFIX}_INCLUDE_DIRS}
)

find_library(raylib_LIBRARY
NAMES raylib
HINTS ${${XPREFIX}_LIBRARY_DIRS}
)
if (raylib_USE_STATIC_LIBS)
find_library(raylib_LIBRARY
NAMES raylib_static
HINTS ${${XPREFIX}_LIBRARY_DIRS}
)
else ()
find_library(raylib_LIBRARY
NAMES raylib
HINTS ${${XPREFIX}_LIBRARY_DIRS}
)
endif ()

set(raylib_LIBRARIES ${raylib_LIBRARY})
set(raylib_LIBRARY_DIRS ${${XPREFIX}_LIBRARY_DIRS})
Expand Down
11 changes: 10 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ if(SHARED)
PUBLIC ${GRAPHICS}
)

if(MSVC)
target_compile_definitions(raylib
PRIVATE $<BUILD_INTERFACE:BUILD_LIBTYPE_SHARED>
INTERFACE $<INSTALL_INTERFACE:USE_LIBTYPE_SHARED>
)
endif()

set(PKG_CONFIG_LIBS_EXTRA "")

set_property(TARGET raylib PROPERTY POSITION_INDEPENDENT_CODE ON)
Expand All @@ -214,7 +221,9 @@ if(SHARED)
if (WIN32)
install(
TARGETS raylib
RUNTIME DESTINATION "lib"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
PUBLIC_HEADER DESTINATION "include"
)
else()
Expand Down

0 comments on commit e41cb77

Please sign in to comment.