CMakeLists.txt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. ##########################################################
  2. # Basic
  3. ##########################################################
  4. cmake_minimum_required(VERSION 3.17)
  5. set(PROJECT_NAME ls_std)
  6. set(RELEASE_VERSION 2020.1.0)
  7. project(${PROJECT_NAME})
  8. ##########################################################
  9. # Compiler Detection
  10. ##########################################################
  11. message("${PROJECT_NAME}: detect compiler...")
  12. if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  13. set(MSVC_COMPILER TRUE)
  14. message("${PROJECT_NAME}: Microsoft Visual Studio detected...")
  15. endif()
  16. if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
  17. set(APPLE_CLANG_COMPILER TRUE)
  18. message("${PROJECT_NAME}: Apple Clang detected...")
  19. endif()
  20. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  21. set(GNU_COMPILER TRUE)
  22. message("${PROJECT_NAME}: GNU Compiler Collection detected...")
  23. endif()
  24. ##########################################################
  25. # Compiler Settings
  26. ##########################################################
  27. message("${PROJECT_NAME}: Setting compiler flags...")
  28. set(CMAKE_CXX_STANDARD 11)
  29. if(MSVC_COMPILER)
  30. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
  31. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  32. endif()
  33. if(APPLE_CLANG_COMPILER)
  34. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
  35. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  36. endif()
  37. if(GNU_COMPILER)
  38. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
  39. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  40. endif()
  41. ######################################################
  42. # Include Directories
  43. ######################################################
  44. message("${PROJECT_NAME}: Adding include directories...")
  45. include_directories(${CMAKE_CURRENT_LIST_DIR}/test/lib/googletest-1.8.1/googletest/include)
  46. include_directories(${CMAKE_CURRENT_LIST_DIR}/source/ls_std/lib/nlohmann_json/include/nlohmann)
  47. include_directories(${CMAKE_CURRENT_LIST_DIR}/source)
  48. ######################################################
  49. # Add Other CMake Dependencies
  50. ######################################################
  51. message("${PROJECT_NAME}: Adding additional cmake dependencies...")
  52. add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/test/lib/googletest-1.8.1)
  53. ##########################################################
  54. # Source Files
  55. ##########################################################
  56. set(SOURCE_FILES
  57. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Integer.hpp
  58. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/base/Class.hpp
  59. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/base/Class.cpp
  60. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Integer.cpp
  61. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/IBoxing.hpp
  62. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/exception/IllegalArithmeticOperationException.hpp
  63. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/base/Types.hpp
  64. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Boolean.hpp
  65. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Boolean.cpp
  66. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/exception/IllegalArgumentException.hpp
  67. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Float.hpp
  68. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Float.cpp
  69. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Double.hpp
  70. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Double.cpp
  71. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/String.hpp
  72. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/String.cpp
  73. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/time/Date.hpp
  74. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/time/Date.cpp
  75. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/File.hpp
  76. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/File.cpp
  77. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/exception/FileOperationException.hpp
  78. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FilePathSeparatorMatch.hpp
  79. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FilePathSeparator.hpp
  80. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/utils/STLUtils.hpp
  81. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Long.hpp
  82. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Long.cpp
  83. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/IWriter.hpp
  84. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FileWriter.hpp
  85. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FileWriter.cpp
  86. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/exception/FileNotFoundException.hpp
  87. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/IReader.hpp
  88. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FileReader.hpp
  89. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FileReader.cpp
  90. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/NewLine.hpp
  91. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/utils/RegexUtils.hpp
  92. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/IStorable.hpp
  93. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/StorableFile.hpp
  94. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/StorableFile.cpp
  95. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/logging/LogLevel.hpp
  96. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FileOutputStream.hpp
  97. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FileOutputStream.cpp
  98. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/logging/Logger.hpp
  99. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/logging/Logger.cpp
  100. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/logging/LogLevel.cpp
  101. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/logging/LogLevelValue.hpp
  102. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/ISerializable.hpp
  103. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONInteger.hpp
  104. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONInteger.cpp
  105. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONLong.hpp
  106. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONLong.cpp
  107. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONString.hpp
  108. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONString.cpp
  109. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONFloat.hpp
  110. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONFloat.cpp
  111. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONDouble.hpp
  112. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONDouble.cpp
  113. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONBoolean.hpp
  114. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/boxing/SerializableJSONBoolean.cpp
  115. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/logic/StateMachine.hpp
  116. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/logic/StateMachine.cpp
  117. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/logic/State.hpp
  118. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/logic/State.cpp
  119. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/logic/StateConnection.hpp
  120. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/logic/StateConnection.cpp
  121. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/logic/StateMachineTypes.hpp
  122. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/logic/SerializableJSONStateConnection.hpp
  123. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/logic/SerializableJSONStateConnection.cpp
  124. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/logic/SerializableJSONState.hpp
  125. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/logic/SerializableJSONState.cpp
  126. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/logic/SerializableJSONStateMachine.hpp
  127. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/serialization/json/logic/SerializableJSONStateMachine.cpp
  128. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLAttribute.hpp
  129. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLAttribute.cpp
  130. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLNode.hpp
  131. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLNode.cpp
  132. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLDocument.hpp
  133. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLDeclaration.hpp
  134. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/base/Version.hpp
  135. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/base/Version.cpp
  136. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLDeclaration.cpp
  137. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLDocument.cpp
  138. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLReader.hpp
  139. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLReader.cpp
  140. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLParseMode.hpp
  141. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLParseData.hpp
  142. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLReaderMock.hpp
  143. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XMLReaderMock.cpp)
  144. set(TEST_FILES
  145. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/IntegerTest.cpp
  146. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/BooleanTest.cpp
  147. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/FloatTest.cpp
  148. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/DoubleTest.cpp
  149. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/StringTest.cpp
  150. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/time/DateTest.cpp
  151. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/FileTest.cpp
  152. ${CMAKE_CURRENT_SOURCE_DIR}/test/TestHelper.hpp
  153. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/base/ClassTest.cpp
  154. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/utils/STLUtilsTest.cpp
  155. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/LongTest.cpp
  156. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/FileWriterTest.cpp
  157. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/FileReaderTest.cpp
  158. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/utils/RegexUtilsTest.cpp
  159. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/StorableFileTest.cpp
  160. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/FileOutputStreamTest.cpp
  161. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/logging/LoggerTest.cpp
  162. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/JSONTest.cpp
  163. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/boxing/SerializableJSONIntegerTest.cpp
  164. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/boxing/SerializableJSONLongTest.cpp
  165. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/boxing/SerializableJSONStringTest.cpp
  166. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/boxing/SerializableJSONFloatTest.cpp
  167. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/boxing/SerializableJSONDoubleTest.cpp
  168. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/boxing/SerializableJSONBooleanTest.cpp
  169. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/logic/StateTest.cpp
  170. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/logic/StateMachineTest.cpp
  171. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/logic/StateConnectionTest.cpp
  172. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/logic/SerializableJSONStateConnectionTest.cpp
  173. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/logic/SerializableJSONStateTest.cpp
  174. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/json/logic/SerializableJSONStateMachineTest.cpp
  175. ${CMAKE_CURRENT_SOURCE_DIR}/test/TestDataFactory.hpp
  176. ${CMAKE_CURRENT_SOURCE_DIR}/test/TestDataFactory.cpp
  177. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XMLAttributeTest.cpp
  178. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XMLNodeTest.cpp
  179. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/base/VersionTest.cpp
  180. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XMLDeclarationTest.cpp
  181. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XMLDocumentTest.cpp
  182. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XMLReaderTest.cpp
  183. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XMLReaderMockTest.cpp)
  184. ##########################################################
  185. # Build
  186. ##########################################################
  187. message("${PROJECT_NAME}: Building version ${RELEASE_VERSION}...")
  188. add_executable(${PROJECT_NAME}_test ${TEST_FILES})
  189. add_library("${PROJECT_NAME}_${RELEASE_VERSION}_static" ${SOURCE_FILES})
  190. add_library("${PROJECT_NAME}_${RELEASE_VERSION}" SHARED ${SOURCE_FILES})
  191. ##########################################################
  192. # Linking
  193. ##########################################################
  194. message("${PROJECT_NAME}: Linking...")
  195. target_link_libraries(${PROJECT_NAME}_test gtest gtest_main "${PROJECT_NAME}_${RELEASE_VERSION}_static")