Skip to content

Commit

Permalink
Cxx: Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
agdavydov81 committed Oct 16, 2023
1 parent 3882288 commit 716d8c8
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ cmake_minimum_required (VERSION 2.8.12)
project (native)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_IN}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_IN}")

if (TARGET)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --target=${TARGET} ${TARGET_EX} --sysroot=${SYSROOT} -I${SYSROOT}/include/c++/v1 -I/usr/${TARGET}/include")
set(TARGET_FLAGS "--target=${TARGET} ${TARGET_EX} --sysroot=${SYSROOT} -I${SYSROOT}/include/c++/v1 -I/usr/${TARGET}/include")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_FLAGS}")
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")

message(STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR})
message(STATUS "CMAKE_C_COMPILER_TARGET: " ${CMAKE_C_COMPILER_TARGET})
message(STATUS "CMAKE_CXX_COMPILER_TARGET: " ${CMAKE_CXX_COMPILER_TARGET})
Expand Down Expand Up @@ -48,6 +49,13 @@ add_definitions(-DDECIMAL_GLOBAL_EXCEPTION_FLAGS=${GLOBAL_FLAGS})
#set(CMAKE_VISIBILITY_INLINES_HIDDEN 0)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if (MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_SCL_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-DNOMINMAX)
endif()

add_subdirectory (../thirdparty/IntelRDFPMathLib20U2/LIBRARY LIBRARY)

add_library(dfp SHARED NativeImpl.c)
Expand Down Expand Up @@ -94,4 +102,8 @@ install(TARGETS dfpStatic DESTINATION ./bin/${CMAKE_BUILD_TYPE}/${INSTALL_SUFFIX

add_executable(demo demo.cpp)
#target_link_libraries(demo LINK_PRIVATE dfp stdc++)
target_link_libraries(demo LINK_PRIVATE dfpStatic) # stdc++)
if (MSVC)
target_link_libraries(demo LINK_PRIVATE dfpStatic)
else()
target_link_libraries(demo LINK_PRIVATE dfpStatic stdc++)
endif()

0 comments on commit 716d8c8

Please sign in to comment.