Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a couple of minor? adjustments #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,38 @@
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#

# CMake build control file for json_spirit
# Created following settings in Jamroot and libs/json/test/Jamfile

cmake_minimum_required( VERSION 2.8 )

project( json_spirit )

if( CMAKE_COMPILER_IS_GNUCXX )
message(STATUS "compiler is ${CMAKE_CXX_COMPILER_ID}" )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope we can leave this one out


if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
add_definitions( -ftemplate-depth=300 )
elseif( MSVC )
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
add_definitions( /wd4996 )
elseif( CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
set (CMAKE_CXX_FLAGS "-std=c++11 -DBOOST_SPIRIT_USE_PHOENIX_V3=1" )
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0" )
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" )
endif()

if( CMAKE_HOST_APPLE )
set (CMAKE_OSX_ARCHITECTURES "x86_64" )
endif()

find_package( Boost COMPONENTS unit_test_framework REQUIRED )
find_package(Boost)

# this didn't work for me
# find_package( Boost COMPONENTS unit_test_framework REQUIRED )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lets CMake know that (for the unit tests) the Boost unit_test_framework component needs to be built, and ensures it gets added to the list of libraries to be linked. It can find it from BOOST_ROOT, normally. What didn't work for you? I might be able to diagnose from the error message.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should say the component needs to have been built - unlike Boost.build, CMake will not do this for you


link_directories(
"${BOOST_ROOT}/stage64/lib"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this is related to the previous issue... at any rate this is Apple-specific and I'd want to at least condition it accordingly

)

include_directories( . ${Boost_INCLUDE_DIRS} )

set(BUILD_SHARED_LIBS false)
file( GLOB SRC_FILES libs/json/src/*.cpp )
add_library( json STATIC ${SRC_FILES} )

Expand Down
Binary file added ciere/.DS_Store
Binary file not shown.
8 changes: 7 additions & 1 deletion ciere/json/detail/io_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,15 @@ namespace ciere { namespace json
}
catch(spirit::qi::expectation_failure<iterator_t> const &){}

// note: the above eats one too many characters from the
// input stream. I don't know where this comes from, so this
// is likely not the correct way to fix this, but I need
// this now
input.unget();

if(skipws_was_set)
{
input.unsetf(std::ios::skipws);
input.setf(std::ios::skipws);
}

return parse_success;
Expand Down
13 changes: 2 additions & 11 deletions ciere/json/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
#include <boost/type_traits/is_floating_point.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/cstdint.hpp>

#include <map>
#include <string>


namespace ciere { namespace json
{
using namespace boost;
// ------------------- ast types --------------------
//
typedef std::string string_t;
Expand All @@ -42,13 +44,10 @@ namespace ciere { namespace json
typedef std::pair<std::string, value> object_member_t;
typedef boost::container::stable_vector<value> array_t;


// nulls always compare
inline bool operator==(null_t,null_t) { return true; }
inline bool operator!=(null_t,null_t) { return false; }



/**
* possible types being stored in the json::value
*/
Expand All @@ -64,7 +63,6 @@ namespace ciere { namespace json
array_type
};


/**
*
*
Expand Down Expand Up @@ -210,8 +208,6 @@ namespace ciere { namespace json
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------



// -------------------------------------------------------------------------------
// array handling
// -------------------------------------------------------------------------------
Expand Down Expand Up @@ -257,7 +253,6 @@ namespace ciere { namespace json
*/
value & erase(int index);


/**
* Returns the number of elements stored if the value is holding an array or
* object type. If it is not an array or object type the method throws
Expand All @@ -268,7 +263,6 @@ namespace ciere { namespace json
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------


// -------------------------------------------------------------------------------
// object handling
// -------------------------------------------------------------------------------
Expand Down Expand Up @@ -345,12 +339,10 @@ namespace ciere { namespace json
// -------------------------------------------------------------------------------
// -------------------------------------------------------------------------------


base_type::variant_type & get_ast() { return base_type::get(); }
base_type::variant_type const & get_ast() const { return base_type::get(); }
};


/**
* Constructs a value containing an array type
*/
Expand All @@ -364,7 +356,6 @@ namespace ciere { namespace json
bool operator==(value const & a, value const & b);
bool operator!=(value const & a, value const & b);
bool operator<(value const & a, value const & b);

}}

#include "detail/value_impl.hpp"
Expand Down
Binary file added libs/.DS_Store
Binary file not shown.
Binary file added libs/json/.DS_Store
Binary file not shown.
30 changes: 7 additions & 23 deletions libs/json/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,15 @@
# CMake build control file for json_spirit tests
include_directories( ../../.. )

add_definitions( -DBOOST_TEST_DYN_LINK )

if( CMAKE_HOST_WIN32 )
# Copy Boost dlls to the test binary directories so they can be found
set( blibs ${Boost_LIBRARIES} )
while( blibs )
list( GET blibs 0 cfg )
list( GET blibs 1 libpath )
# create the corresponding dll name (libpath will be .lib)
get_filename_component( dllname ${libpath} NAME_WE )
get_filename_component( dllpath ${libpath} PATH )
set( dllpath "${dllpath}/${dllname}.dll" )
if( cfg STREQUAL optimized )
file( COPY ${dllpath} DESTINATION Release )
else()
file( COPY ${dllpath} DESTINATION Debug )
endif()
list( REMOVE_AT blibs 0 1 )
endwhile()
endif()

foreach( tname
construct value_basic value_array value_object value_non_container get get_as parser_test )
construct value_basic value_array value_object value_non_container get get_as parser_test
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't remove Windows support, although at some level I sympathize :)

add_executable( ${tname} ${tname}.cpp )
target_link_libraries( ${tname} json ${Boost_LIBRARIES} )
target_link_libraries( ${tname}
json
debug libboost_unit_test_framework-clang-darwin-mt-d-1_55.a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the find_package with the unit_test_framework had succeeded, Boost_LIBRARIES would have contained the names and paths of these libraries without any need to hardcode them. So I think we need to start with why that's not working.

optimized libboost_unit_test_framework-clang-darwin-mt-d-1_55.a
)
add_test( ${tname} ${tname} )
endforeach()