I want to #define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
so as to use nanosecond resolution in boost datetime.
I want to use this nanosecond across the whole shared library I'm going to compile.
So where should I put this line, #define BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
?
I previously wanted to define it in the CMakeLists.txt
file with add_compile_definitions(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
.
However, it does not take effect. This is because within the library,
cout << "nanoseconds per unit: " << pt::time_duration(0, 0, 0, 1).total_nanoseconds() << endl;
still gives nanoseconds per unit: 1000
Here's the CMakeLists.txt
,
cmake_minimum_required(VERSION 3.22)
project(project_name)
set(CMAKE_CXX_STANDARD 17)
add_compile_definitions(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
find_package( Boost COMPONENTS filesystem iostreams REQUIRED )
include_directories( ${Boost_INCLUDE_DIR} )
include_directories( include )
file(GLOB SOURCES include/*.h src/*.cpp)
add_library(project_name SHARED library.cpp ${SOURCES})
set_target_properties(project_name PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(project_name ${Boost_LIBRARIES})