|
|
@@ -5,19 +5,14 @@ project(pocketpy)
|
|
|
set(CMAKE_C_STANDARD 11)
|
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
|
|
|
|
-# use UNITY_BUILD if CMake version >= 3.16
|
|
|
-if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
|
|
|
- option(PK_BUILD_WITH_UNITY "" TRUE)
|
|
|
-else()
|
|
|
- option(PK_BUILD_WITH_UNITY "" FALSE)
|
|
|
-endif()
|
|
|
+include(CMakeOptions.txt)
|
|
|
|
|
|
if(WIN32)
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
endif()
|
|
|
|
|
|
if(MSVC)
|
|
|
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8 /jumptablerdata /GS-")
|
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8 /jumptablerdata")
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /experimental:c11atomics")
|
|
|
add_compile_options(/wd4267 /wd4244)
|
|
|
|
|
|
@@ -25,6 +20,10 @@ if(MSVC)
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Ox")
|
|
|
add_definitions(-DNDEBUG)
|
|
|
endif()
|
|
|
+
|
|
|
+ if(PK_ENABLE_DETERMINISM)
|
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Oi-")
|
|
|
+ endif()
|
|
|
else()
|
|
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
|
|
@@ -35,44 +34,32 @@ else()
|
|
|
if(APPLE)
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-shorten-64-to-32")
|
|
|
endif()
|
|
|
+
|
|
|
+ if(PK_ENABLE_DETERMINISM)
|
|
|
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexcess-precision=standard -ffp-contract=off")
|
|
|
+ endif()
|
|
|
endif()
|
|
|
|
|
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
|
|
|
file(GLOB_RECURSE POCKETPY_SRC ${CMAKE_CURRENT_LIST_DIR}/src/*.c)
|
|
|
|
|
|
-option(PK_ENABLE_OS "" OFF)
|
|
|
+
|
|
|
if(PK_ENABLE_OS)
|
|
|
add_definitions(-DPK_ENABLE_OS=1)
|
|
|
endif()
|
|
|
|
|
|
-option(PK_BUILD_MODULE_LZ4 "" OFF)
|
|
|
if(PK_BUILD_MODULE_LZ4)
|
|
|
add_subdirectory(3rd/lz4)
|
|
|
include_directories(3rd/lz4)
|
|
|
add_definitions(-DPK_BUILD_MODULE_LZ4)
|
|
|
endif()
|
|
|
|
|
|
-option(PK_BUILD_MODULE_LIBHV "" OFF)
|
|
|
if(PK_BUILD_MODULE_LIBHV)
|
|
|
add_subdirectory(3rd/libhv)
|
|
|
include_directories(3rd/libhv/include)
|
|
|
add_definitions(-DPK_BUILD_MODULE_LIBHV)
|
|
|
endif()
|
|
|
|
|
|
-# PK_IS_MAIN determines whether the project is being used from root
|
|
|
-# or if it is added as a dependency (through add_subdirectory for example).
|
|
|
-if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
- set(PK_IS_MAIN TRUE)
|
|
|
- option(PK_BUILD_SHARED_LIB "Build shared library" OFF)
|
|
|
- option(PK_BUILD_STATIC_LIB "Build static library" OFF)
|
|
|
-else()
|
|
|
- set(PK_IS_MAIN FALSE)
|
|
|
- option(PK_BUILD_SHARED_LIB "Build shared library" OFF)
|
|
|
- option(PK_BUILD_STATIC_LIB "Build static library" ON)
|
|
|
-endif()
|
|
|
-
|
|
|
-option(PK_BUILD_STATIC_MAIN "Build static main" OFF)
|
|
|
-
|
|
|
if(PK_BUILD_SHARED_LIB)
|
|
|
message(">> Building shared library")
|
|
|
add_library(${PROJECT_NAME} SHARED ${POCKETPY_SRC})
|
|
|
@@ -92,7 +79,11 @@ else()
|
|
|
endif()
|
|
|
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
- target_link_libraries(${PROJECT_NAME} m)
|
|
|
+ if(NOT PK_ENABLE_DETERMINISM)
|
|
|
+ # use platform libm
|
|
|
+ target_link_libraries(${PROJECT_NAME} m)
|
|
|
+ endif()
|
|
|
+
|
|
|
if(PK_ENABLE_OS)
|
|
|
target_link_libraries(${PROJECT_NAME} dl)
|
|
|
endif()
|