Enable Link Time Code Generation for UWP builds. Tweak optimization flags for individual projects to make SDK both smaller and faster in common cases.
@@ -30,12 +30,12 @@ if(WIN32)
add_definitions("-DNOMINMAX -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DGL_GLEXT_PROTOTYPES")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4244")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /std:c++17 /Zc:__cplusplus /EHs /GR")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Os")
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Os")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /WINMD /NODEFAULTLIB:vccorlib /NODEFAULTLIB:msvcrt vccorlib.lib msvcrt.lib")
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Os /GL")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Os /GL")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /WINMD vccorlib.lib")
+ set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG")
set(CMAKE_VS_WINRT_EXTENSIONS ON)
- set(VS_WINRT_EXTENSIONS ON)
endif(WIN32)
if(IOS)
@@ -132,9 +132,25 @@ endforeach()
set(SDK_SUBPROJECTS "${SDK_CARTO_SUBPROJECTS}" "${SDK_EXTERNAL_SUBPROJECTS}")
+# When in single library mode, apply compilation flags to individual projects.
if(SINGLE_LIBRARY)
foreach(SDK_SUBPROJECT IN ITEMS ${SDK_SUBPROJECTS})
set(SUBPROJECT_FLAGS "${${SDK_SUBPROJECT}_FLAGS}")
+ if(CMAKE_BUILD_TYPE MATCHES "Release|RELEASE")
+ if(ANDROID OR IOS)
+ if(SDK_SUBPROJECT MATCHES "^(vt|mapnikvt|cartocss|freetype|tess2|zlib|brotli)$")
+ set(SUBPROJECT_FLAGS ${SUBPROJECT_FLAGS} "-O2")
+ else()
+ set(SUBPROJECT_FLAGS ${SUBPROJECT_FLAGS} "-Oz")
+ endif()
+ elseif(WIN32)
+ if(SDK_SUBPROJECT MATCHES "^(vt|mapnikvt|cartocss|freetype|tess2|zlib|brotli)$")
+ set(SUBPROJECT_FLAGS ${SUBPROJECT_FLAGS} "/Ox")
+ else()
+ set(SUBPROJECT_FLAGS ${SUBPROJECT_FLAGS} "/Os")
+ endif()
+ endif()
+ endif()
if(SUBPROJECT_FLAGS)
set_source_files_properties(${${SDK_SUBPROJECT}_SRC_FILES} PROPERTIES COMPILE_OPTIONS "${SUBPROJECT_FLAGS}")
endif()
