CMakeLists.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. CMAKE_MINIMUM_REQUIRED( VERSION 2.6 )
  2. PROJECT( OpenDDL-Parser )
  3. SET ( OPENDDL_PARSER_VERSION_MAJOR 0 )
  4. SET ( OPENDDL_PARSER_VERSION_MINOR 1 )
  5. SET ( OPENDDL_PARSER_VERSION_PATCH 0 )
  6. SET ( OPENDDL_PARSER_VERSION ${OPENDDL_PARSER_VERSION_MAJOR}.${OPENDDL_PARSER_VERSION_MINOR}.${OPENDDL_PARSER_VERSION_PATCH} )
  7. SET ( PROJECT_VERSION "${OPENDDL_PARSER_VERSION}" )
  8. option( DDL_USE_CPP11 "Set to ON to use C++11 features ( always on on windows )." ON )
  9. option( DDL_DEBUG_OUTPUT "Set to ON to use output debug texts" OFF )
  10. option( DDL_STATIC_LIBRARY "Set to ON to build static libary of OpenDDL Parser." ON )
  11. option( COVERALLS "Generate coveralls data" OFF )
  12. if ( DDL_USE_CPP11 )
  13. if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
  14. set( OPENDDL_CXXFLAGS -std=c++0x )
  15. elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  16. set( OPENDDL_CXXFLAGS --std=c++11 )
  17. endif()
  18. else( DDL_USE_CPP11 )
  19. add_definitions( -DOPENDDL_NO_USE_CPP11 )
  20. endif( DDL_USE_CPP11)
  21. if( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
  22. find_package(Threads)
  23. else()
  24. add_definitions( -D_CRT_SECURE_NO_WARNINGS )
  25. endif()
  26. if ( DDL_STATIC_LIBRARY )
  27. add_definitions( -DOPENDDL_STATIC_LIBARY )
  28. endif()
  29. add_definitions( -DOPENDDLPARSER_BUILD )
  30. add_definitions( -D_VARIADIC_MAX=10 )
  31. add_definitions( -DGTEST_HAS_PTHREAD=0 )
  32. if ( DDL_DEBUG_OUTPUT )
  33. add_definitions( -DDDL_DEBUG_HEADER_NAME)
  34. endif()
  35. INCLUDE_DIRECTORIES(
  36. ./
  37. include/
  38. contrib/gtest-1.7.0/include
  39. contrib/gtest-1.7.0/
  40. )
  41. link_directories(
  42. ${CMAKE_HOME_DIRECTORY}/lib
  43. )
  44. set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake )
  45. SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
  46. SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/lib )
  47. SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_HOME_DIRECTORY}/bin )
  48. if( WIN32 AND NOT CYGWIN )
  49. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc" ) # Force to always compile with W4
  50. if( CMAKE_CXX_FLAGS MATCHES "/W[0-4]" )
  51. string( REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
  52. else()
  53. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4" )
  54. endif()
  55. elseif( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
  56. # Update if necessary
  57. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic ${OPENDDL_CXXFLAGS}")
  58. elseif ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
  59. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic ${OPENDDL_CXXFLAGS} -Wwrite-strings")
  60. endif()
  61. if (COVERALLS)
  62. include(Coveralls)
  63. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
  64. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
  65. endif()
  66. # Include the doc component.
  67. FIND_PACKAGE( doxygen )
  68. IF ( DOXYGEN_FOUND )
  69. CONFIGURE_FILE( doc/openddlparser_doc.in doc/doxygenfile @ONLY )
  70. ADD_CUSTOM_TARGET( doc ALL ${DOXYGEN_EXECUTABLE} doc/doxygenfile
  71. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  72. COMMENT "Generating API documentation with Doxygen" VERBATIM )
  73. ENDIF ( DOXYGEN_FOUND )
  74. SET ( openddl_parser_src
  75. code/OpenDDLCommon.cpp
  76. code/OpenDDLExport.cpp
  77. code/OpenDDLParser.cpp
  78. code/OpenDDLStream.cpp
  79. code/DDLNode.cpp
  80. code/Value.cpp
  81. include/openddlparser/OpenDDLCommon.h
  82. include/openddlparser/OpenDDLExport.h
  83. include/openddlparser/OpenDDLParser.h
  84. include/openddlparser/OpenDDLParserUtils.h
  85. include/openddlparser/OpenDDLStream.h
  86. include/openddlparser/DDLNode.h
  87. include/openddlparser/Value.h
  88. README.md
  89. )
  90. SOURCE_GROUP( code FILES ${openddl_parser_src} )
  91. if ( DDL_STATIC_LIBRARY )
  92. ADD_LIBRARY( openddl_parser STATIC
  93. ${openddl_parser_src}
  94. )
  95. else()
  96. ADD_LIBRARY( openddl_parser SHARED
  97. ${openddl_parser_src}
  98. )
  99. endif()
  100. SET ( GTEST_PATH contrib/gtest-1.7.0 )
  101. SET ( gtest_src
  102. ${GTEST_PATH}/src/gtest-death-test.cc
  103. ${GTEST_PATH}/src/gtest-filepath.cc
  104. ${GTEST_PATH}/src/gtest-internal-inl.h
  105. ${GTEST_PATH}/src/gtest-port.cc
  106. ${GTEST_PATH}/src/gtest-printers.cc
  107. ${GTEST_PATH}/src/gtest-test-part.cc
  108. ${GTEST_PATH}/src/gtest-typed-test.cc
  109. ${GTEST_PATH}/src/gtest.cc
  110. ${GTEST_PATH}/src/gtest_main.cc
  111. )
  112. SET( openddl_parser_unittest_src
  113. test/UnitTestCommon.h
  114. test/DDLNodeTest.cpp
  115. test/OpenDDLCommonTest.cpp
  116. test/OpenDDLExportTest.cpp
  117. test/OpenDDLParserTest.cpp
  118. test/OpenDDLParserUtilsTest.cpp
  119. test/OpenDDLStreamTest.cpp
  120. test/OpenDDLIntegrationTest.cpp
  121. test/ValueTest.cpp
  122. test/OpenDDLDefectsTest.cpp
  123. )
  124. SOURCE_GROUP( code FILES ${openddl_parser_unittest_src} )
  125. SOURCE_GROUP( gtest FILES ${gtest_src} )
  126. ADD_EXECUTABLE( openddl_parser_unittest
  127. ${gtest_src}
  128. ${openddl_parser_unittest_src}
  129. )
  130. target_link_libraries( openddl_parser_unittest openddl_parser ${CMAKE_THREAD_LIBS_INIT} )
  131. SET( openddl_parser_demo_src
  132. demo/main.cpp
  133. )
  134. if (COVERALLS)
  135. set(COVERAGE_SRCS ${gtest_src} ${openddl_parser_unittest_src} )
  136. # Create the coveralls target.
  137. coveralls_setup(
  138. "${COVERAGE_SRCS}" # The source files.
  139. ON # If we should upload.
  140. "${PROJECT_SOURCE_DIR}/cmake/") # (Optional) Alternate project cmake module path.
  141. endif()
  142. ADD_EXECUTABLE( openddl_parser_demo
  143. ${openddl_parser_demo_src}
  144. )
  145. target_link_libraries( openddl_parser_demo openddl_parser )