|
|
|
@ -1,10 +1,4 @@ |
|
|
|
|
|
|
|
|
|
include_directories("${GLFW_SOURCE_DIR}/src" |
|
|
|
|
"${GLFW_BINARY_DIR}/src" |
|
|
|
|
${glfw_INCLUDE_DIRS}) |
|
|
|
|
|
|
|
|
|
add_definitions(-D_GLFW_USE_CONFIG_H) |
|
|
|
|
|
|
|
|
|
set(common_HEADERS internal.h |
|
|
|
|
"${GLFW_BINARY_DIR}/src/glfw_config.h" |
|
|
|
|
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" |
|
|
|
@ -58,37 +52,66 @@ endif() |
|
|
|
|
|
|
|
|
|
add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) |
|
|
|
|
set_target_properties(glfw PROPERTIES |
|
|
|
|
OUTPUT_NAME "${GLFW_LIB_NAME}" |
|
|
|
|
VERSION ${GLFW_VERSION} |
|
|
|
|
SOVERSION ${GLFW_VERSION_MAJOR} |
|
|
|
|
POSITION_INDEPENDENT_CODE ON |
|
|
|
|
FOLDER "GLFW3") |
|
|
|
|
|
|
|
|
|
target_compile_definitions(glfw PRIVATE -D_GLFW_USE_CONFIG_H) |
|
|
|
|
target_include_directories(glfw PRIVATE |
|
|
|
|
"${GLFW_SOURCE_DIR}/src" |
|
|
|
|
"${GLFW_BINARY_DIR}/src" |
|
|
|
|
${glfw_INCLUDE_DIRS}) |
|
|
|
|
|
|
|
|
|
# HACK: When building on MinGW, WINVER and UNICODE need to be defined before |
|
|
|
|
# the inclusion of stddef.h (by glfw3.h), which is itself included before |
|
|
|
|
# win32_platform.h. We define them here until a saner solution can be found |
|
|
|
|
# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack. |
|
|
|
|
target_compile_definitions(glfw PRIVATE |
|
|
|
|
"$<$<BOOL:${MINGW}>:UNICODE;WINVER=0x0501>") |
|
|
|
|
|
|
|
|
|
# Enable a reasonable set of warnings (no, -Wextra is not reasonable) |
|
|
|
|
target_compile_options(glfw PRIVATE |
|
|
|
|
"$<$<C_COMPILER_ID:Clang>:-Wall>" |
|
|
|
|
"$<$<C_COMPILER_ID:GNU>:-Wall>") |
|
|
|
|
|
|
|
|
|
if (BUILD_SHARED_LIBS) |
|
|
|
|
if (WIN32) |
|
|
|
|
# The GLFW DLL needs a special compile-time macro and import library name |
|
|
|
|
set_target_properties(glfw PROPERTIES PREFIX "") |
|
|
|
|
|
|
|
|
|
if (MINGW) |
|
|
|
|
# Remove the lib prefix on the DLL (but not the import library |
|
|
|
|
set_target_properties(glfw PROPERTIES PREFIX "") |
|
|
|
|
|
|
|
|
|
# Add a suffix to the import library to avoid naming conflicts |
|
|
|
|
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.a") |
|
|
|
|
else() |
|
|
|
|
# Add a suffix to the import library to avoid naming conflicts |
|
|
|
|
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib") |
|
|
|
|
endif() |
|
|
|
|
elseif (APPLE) |
|
|
|
|
# Append -fno-common to the compile flags to work around a bug in |
|
|
|
|
# Apple's GCC |
|
|
|
|
get_target_property(glfw_CFLAGS glfw COMPILE_FLAGS) |
|
|
|
|
if (NOT glfw_CFLAGS) |
|
|
|
|
set(glfw_CFLAGS "") |
|
|
|
|
endif() |
|
|
|
|
# Add -fno-common to work around a bug in Apple's GCC |
|
|
|
|
target_compile_options(glfw PRIVATE "-fno-common") |
|
|
|
|
|
|
|
|
|
set_target_properties(glfw PROPERTIES |
|
|
|
|
COMPILE_FLAGS "${glfw_CFLAGS} -fno-common" |
|
|
|
|
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}") |
|
|
|
|
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}") |
|
|
|
|
elseif (UNIX) |
|
|
|
|
# Hide symbols not explicitly tagged for export from the shared library |
|
|
|
|
target_compile_options(glfw PRIVATE "-fvisibility=hidden") |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
target_link_libraries(glfw ${glfw_LIBRARIES}) |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
if (MSVC) |
|
|
|
|
target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
if (BUILD_SHARED_LIBS AND UNIX) |
|
|
|
|
# On Unix-like systems, shared libraries can use the soname system. |
|
|
|
|
set_target_properties(glfw PROPERTIES OUTPUT_NAME glfw) |
|
|
|
|
else() |
|
|
|
|
set_target_properties(glfw PROPERTIES OUTPUT_NAME glfw3) |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
if (GLFW_INSTALL) |
|
|
|
|
install(TARGETS glfw EXPORT glfwTargets DESTINATION lib${LIB_SUFFIX}) |
|
|
|
|
endif() |
|
|
|
|