diff --git a/cmake/win/WinFunctions.cmake b/cmake/win/WinFunctions.cmake index b7f0267..d693af3 100644 --- a/cmake/win/WinFunctions.cmake +++ b/cmake/win/WinFunctions.cmake @@ -4,4 +4,17 @@ set(GLFW3_STATIC_INIT ON) set(LIBRW_STATIC_RUNTIME_DEFAULT ON) function(librw_platform_target TARGET) + cmake_parse_arguments(LPT "PROVIDES_WINMAIN" "" "" ${ARGN}) + get_target_property(TARGET_TYPE "${TARGET}" TYPE) + + if(MINGW) + if(LPT_PROVIDES_WINMAIN AND TARGET_TYPE MATCHES "^(INTERFACE|SHARED|STATIC)_LIBRARY$") + # Start with the WinMain symbol marked as undefined. + # This will prevent the linker ignoring a WinMain symbol. + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + target_link_options(${TARGET} INTERFACE -Wl,--undefined,_WinMain@16) + endif() + target_link_options(${TARGET} INTERFACE -Wl,--undefined,WinMain) + endif() + endif() endfunction() diff --git a/skeleton/CMakeLists.txt b/skeleton/CMakeLists.txt index 3083adc..276e9d7 100644 --- a/skeleton/CMakeLists.txt +++ b/skeleton/CMakeLists.txt @@ -31,17 +31,19 @@ set_target_properties(librw_skeleton EXPORT_NAME skeleton ) -target_link_libraries(librw_skeleton - PRIVATE - librw -) - target_include_directories(librw_skeleton PUBLIC $ $ ) +target_link_libraries(librw_skeleton + PRIVATE + librw +) + +librw_platform_target(librw_skeleton PROVIDES_WINMAIN INSTALL) + if(LIBRW_INSTALL) install( FILES diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5b16901..0521351 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -192,6 +192,8 @@ elseif(LIBRW_PLATFORM_D3D9) ) endif() +librw_platform_target(librw INSTALL) + if(LIBRW_INSTALL) install( FILES