CMake: Fix Windows static build

This commit is contained in:
Vicki Pfau 2019-06-22 10:35:21 -07:00
parent 98d2671c6d
commit 2d04d03d32
1 changed files with 3 additions and 1 deletions

View File

@ -785,6 +785,7 @@ source_group("Extra features" FILES ${FEATURE_SRC})
source_group("Third-party code" FILES ${THIRD_PARTY_SRC}) source_group("Third-party code" FILES ${THIRD_PARTY_SRC})
# Platform binaries # Platform binaries
set(OS_DEFINES)
if(DEFINED 3DS) if(DEFINED 3DS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/3ds ${CMAKE_CURRENT_BINARY_DIR}/3ds) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/3ds ${CMAKE_CURRENT_BINARY_DIR}/3ds)
endif() endif()
@ -841,12 +842,13 @@ if(NOT SKIP_LIBRARY)
if(BUILD_STATIC) if(BUILD_STATIC)
add_library(${BINARY_NAME}-static STATIC ${SRC}) add_library(${BINARY_NAME}-static STATIC ${SRC})
target_include_directories(${BINARY_NAME}-static BEFORE PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include) target_include_directories(${BINARY_NAME}-static BEFORE PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include)
set_target_properties(${BINARY_NAME}-static PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}" COMPILE_OPTIONS "${FEATURE_FLAGS}") set_target_properties(${BINARY_NAME}-static PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES};BUILD_STATIC" COMPILE_OPTIONS "${FEATURE_FLAGS}")
install(TARGETS ${BINARY_NAME}-static DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME}) install(TARGETS ${BINARY_NAME}-static DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME})
add_dependencies(${BINARY_NAME}-static version-info) add_dependencies(${BINARY_NAME}-static version-info)
endif() endif()
else() else()
add_library(${BINARY_NAME} STATIC ${SRC}) add_library(${BINARY_NAME} STATIC ${SRC})
list(APPEND OS_DEFINES BUILD_STATIC)
endif() endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/mgba-util) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/mgba-util)