Skip to content

Commit

Permalink
Cxx: Fix compilation, prepare for Conan compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
agdavydov81 committed Nov 2, 2023
1 parent 0524c53 commit d29dcf5
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
42 changes: 18 additions & 24 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required (VERSION 3.22)
project (native)
project (native VERSION ${VERSION})

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
Expand Down Expand Up @@ -39,14 +39,17 @@ if (JAVA_PREFIX)
\"CMAKE_C_COMPILER_VERSION\": \"${CMAKE_C_COMPILER_VERSION}\",\n\
\"CMAKE_C_FLAGS\": \"${CMAKE_C_FLAGS}\",\n\
}")
set(LINKTYPE SHARED)
endif()

if (NOT LINKTYPE)
set(LINKTYPE STATIC)
endif()

set(CALL_BY_REF "0" CACHE STRING "The numerical arguments and results are passed by reference")
set(GLOBAL_RND "1" CACHE STRING "The rounding mode is a global variable _IDEC_glbround")
set(GLOBAL_FLAGS "1" CACHE STRING "The exception status flags are represented by a global variable _IDEC_glbflags")

set(LINKTYPE "STATIC" CACHE STRING "The libraries linking type")

if(APPLE)
add_definitions(-DAPPLE)
add_definitions(-DMINIMAL_SILENT_MODE_EXCEPTION_HANDLER)
Expand Down Expand Up @@ -112,29 +115,20 @@ if (JAVA_PREFIX)
target_compile_definitions(dfp PRIVATE JAVA_PREFIX=${JAVA_PREFIX})
endif()
set_target_properties(dfp PROPERTIES OUTPUT_NAME "ddfp${VERSION_SUFFIX}")
set_target_properties(dfp PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
if (NOT JAVA_PREFIX)
set_target_properties(dfp PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}")
endif()
install(TARGETS dfp)

add_library(dfpmath ${LINKTYPE} ${BID_SRCS} src/NativeMathImpl.c)
include_directories(src/thirdparty/IntelRDFPMathLib20U2/LIBRARY/src)
target_compile_definitions(dfpmath PRIVATE API_PREFIX=ddfpmath${VERSION_SUFFIX}_)
if (JAVA_MATH_PREFIX)
target_compile_definitions(dfpmath PRIVATE JAVA_PREFIX=${JAVA_MATH_PREFIX})
add_library(dfpmath ${LINKTYPE} ${BID_SRCS} src/NativeMathImpl.c)
include_directories(src/thirdparty/IntelRDFPMathLib20U2/LIBRARY/src)
target_compile_definitions(dfpmath PRIVATE API_PREFIX=ddfpmath${VERSION_SUFFIX}_)
if (JAVA_MATH_PREFIX)
target_compile_definitions(dfpmath PRIVATE JAVA_PREFIX=${JAVA_MATH_PREFIX})
endif()
set_target_properties(dfpmath PROPERTIES OUTPUT_NAME "ddfpmath${VERSION_SUFFIX}")
install(TARGETS dfpmath)
endif()
set_target_properties(dfpmath PROPERTIES OUTPUT_NAME "ddfpmath${VERSION_SUFFIX}")
install(TARGETS dfpmath)


#add_library(dfpStatic STATIC NativeImpl.c ${BID_SRCS})
#include_directories(../thirdparty/IntelRDFPMathLib20U2/LIBRARY/src)
#target_compile_definitions(dfpStatic PRIVATE API_PREFIX=ddfp${VERSION_SUFFIX}_ NOJAVA)
#set_target_properties(dfpStatic PROPERTIES OUTPUT_NAME "ddfpStatic${VERSION_SUFFIX}")
#install(TARGETS dfpStatic DESTINATION ./bin/${CMAKE_BUILD_TYPE}/${INSTALL_SUFFIX})

#if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# add_executable(demoStatic demo.cpp)
# target_link_libraries(demoStatic LINK_PRIVATE dfpStatic)

# add_executable(demo demo.cpp)
# target_link_libraries(demo LINK_PRIVATE dfp)
#endif()
include(CPack)
5 changes: 3 additions & 2 deletions native/src/NativeImplToString.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "NativeImpl.h"
#include <bid_internal.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include "NativeImplToString.h"
#include <bid_conf.h>
#include <bid_functions.h>
#include <bid_internal.h>

static const BID_UINT64 DFP_NAN_NULL = 0xFFFFFFFFFFFFFF80ull; // = -0x80L;
static const BID_UINT64 MASK_INFINITY_AND_NAN = 0x7800000000000000ull;
Expand Down
3 changes: 2 additions & 1 deletion native/src/NativeImplToString.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <bid_internal.h>
#include <bid_conf.h>
#include <bid_functions.h>

BID_EXTERN_C const char * dfp64_to_string(BID_UINT64 value);
BID_EXTERN_C const char * dfp64_to_string_2(BID_UINT64 value, char decimalMark);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/

#ifndef _BID_CONF_H
#define _BID_CONF_H

#ifndef BID_EXTERN_C
#if defined(__cplusplus)
#define BID_EXTERN_C extern "C"
#else
#define BID_EXTERN_C
#define BID_EXTERN_C extern
#endif

#ifndef _BID_CONF_H
#define _BID_CONF_H
#endif

// Name Changes

Expand Down Expand Up @@ -995,11 +997,11 @@ typedef unsigned int _IDEC_flags; // could be a struct with diagnostic inf
#endif

#if DECIMAL_GLOBAL_ROUNDING
BID_EXTERN_C BID_THREAD _IDEC_round _IDEC_glbround;
BID_THREAD _IDEC_round _IDEC_glbround;
#endif

#if DECIMAL_GLOBAL_EXCEPTION_FLAGS
BID_EXTERN_C BID_THREAD _IDEC_flags _IDEC_glbflags;
BID_THREAD _IDEC_flags _IDEC_glbflags;
#endif

#if DECIMAL_ALTERNATE_EXCEPTION_HANDLING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@
THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/

#ifndef _BID_FUNCTIONS_H
#define _BID_FUNCTIONS_H

#ifndef BID_EXTERN_C
#if defined(__cplusplus)
#define BID_EXTERN_C extern "C"
#else
#define BID_EXTERN_C
#define BID_EXTERN_C extern
#endif
#endif

#ifndef _BID_FUNCTIONS_H
#define _BID_FUNCTIONS_H

#if !defined (__GNUC__) || defined(__QNX__)
#include <wchar.h>
Expand Down

0 comments on commit d29dcf5

Please sign in to comment.