cmake_minimum_required(VERSION 3.8) # CMake project file for Rampant Pixel's foundation_lib, to replace configure.py script file. # - fuck python. project(foundation_lib C) include_directories(./) add_definitions("-DFOUNDATION_COMPILE=1") if ( NOT CMAKE_BUILD_TYPE) # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up # differentiation between debug and release builds. message("Setting up CMAKE_BUILD_TYPE") set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE) endif () if (CMAKE_C_COMPILER_ID STREQUAL "Clang") # using Clang set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funit-at-a-time -fstrict-aliasing -fno-math-errno -ffinite-math-only -funsafe-math-optimizations -fno-trapping-math -ffast-math -g") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -funroll-loops -O3") set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -funroll-loops -O4") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") # using GCC set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -funit-at-a-time -fstrict-aliasing -fno-math-errno -ffinite-math-only -funsafe-math-optimizations -fno-trapping-math -ffast-math -g") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -funroll-loops -O3") set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -funroll-loops -O4") elseif (CMAKE_C_COMPILER_ID STREQUAL "Intel") # using Intel C++ elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zi /W3 /WX /Oi /Oy- /MT /GS- /Gy- /GF- /Gm- /Qpar- /fp:fast /fp:except- /Zc:forScope /Zc:wchar_t /GR- /openmp-") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Od") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Od") set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /Ox /Ob2 /Ot /GT /GL") endif() if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions("-DBUILD_DEBUG") elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") add_definitions("-DBUILD_PROFILE") elseif(CMAKE_BUILD_TYPE STREQUAL "Release") add_definitions("-DBUILD_RELEASE") elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") add_definitions("-DBUILD_DEPLOY") else() add_definitions("-DBUILD_DEBUG") endif() set(FOUNDATION_SOURCES ./foundation/android.c ./foundation/array.c ./foundation/assert.c ./foundation/assetstream.c ./foundation/atomic.c ./foundation/base64.c ./foundation/beacon.c ./foundation/bitbuffer.c ./foundation/blowfish.c ./foundation/bufferstream.c ./foundation/environment.c ./foundation/error.c ./foundation/event.c ./foundation/exception.c ./foundation/foundation.c ./foundation/fs.c ./foundation/hash.c ./foundation/hashmap.c ./foundation/hashtable.c ./foundation/json.c ./foundation/library.c ./foundation/log.c ./foundation/main.c ./foundation/md5.c ./foundation/memory.c ./foundation/mutex.c ./foundation/objectmap.c ./foundation/path.c ./foundation/pipe.c ./foundation/process.c ./foundation/profile.c ./foundation/radixsort.c ./foundation/random.c ./foundation/regex.c ./foundation/ringbuffer.c ./foundation/sha.c ./foundation/semaphore.c ./foundation/stacktrace.c ./foundation/stream.c ./foundation/string.c ./foundation/system.c ./foundation/thread.c ./foundation/time.c ./foundation/tizen.c ./foundation/uuid.c ./foundation/uuidmap.c # ./foundation/version.c ) if(APPLE) set(FOUNDATION_SOURCES ${FOUNDATION_SOURCES} ./foundation/delegate.m ./foundation/environment.m ./foundation/fs.m ./foundation/system.m ) endif() add_library(foundation STATIC ${FOUNDATION_SOURCES}) install(DIRECTORY foundation DESTINATION include FILES_MATCHING PATTERN "*.h") install(TARGETS foundation LIBRARY DESTINATION lib/ ARCHIVE DESTINATION lib/)