1cmake_minimum_required(VERSION 3.4.1) 2 3set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Werror -Wthread-safety" ) 4set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS -O3 -fPIC" ) 5set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions" ) 6set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti" ) 7set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections" ) 8if ( DEFINED GAMESDK_THREAD_CHECKS ) 9 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGAMESDK_THREAD_CHECKS=${GAMESDK_THREAD_CHECKS}" ) 10endif() 11 12set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections" ) 13set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-s" ) 14 15set ( SOURCE_LOCATION .) 16 17include_directories( ../../include ) 18include_directories( ../common ) 19 20message( STATUS "Building swappy_static to ${CMAKE_CURRENT_BINARY_DIR}/build" ) 21add_library( swappy_static 22 23 STATIC 24 25 ${SOURCE_LOCATION}/ChoreographerFilter.cpp 26 ${SOURCE_LOCATION}/ChoreographerThread.cpp 27 ${SOURCE_LOCATION}/EGL.cpp 28 ${SOURCE_LOCATION}/FrameStatistics.cpp 29 ${SOURCE_LOCATION}/CpuInfo.cpp 30 ${SOURCE_LOCATION}/SystemProperties.cpp 31 ${SOURCE_LOCATION}/Swappy.cpp 32 ${SOURCE_LOCATION}/Settings.cpp 33 ${SOURCE_LOCATION}/Thread.cpp 34 ${SOURCE_LOCATION}/Swappy.cpp 35 ${SOURCE_LOCATION}/Swappy_c.cpp 36 37 # Add new source files here 38 ) 39 40set_target_properties( swappy_static PROPERTIES 41 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build ) 42 43add_library( swappy 44 45 SHARED 46 47 ${SOURCE_LOCATION}/Swappy_c.cpp) 48 # Looks like I need to specify at least one file to build, 49 # the result .so size suggests it's including the rest of the 50 # source files from the library 51 # also, removing the target_link to the static library 52 # fails the build 53 54 55 target_link_libraries( swappy 56 57 swappy_static 58 android 59 EGL 60 GLESv2 61 log ) 62