CMakeLists.txt 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. ####################################################################################################################
  2. ####################################################################################################################
  3. ####################################################################################################################
  4. # General
  5. ####################################################################################################################
  6. ####################################################################################################################
  7. ####################################################################################################################
  8. ##########################################################
  9. # Basic
  10. ##########################################################
  11. cmake_minimum_required(VERSION 3.17)
  12. project(ls_std VERSION 2022.3.0)
  13. set(MODULE_NAME_BOXING ls_std_boxing)
  14. set(MODULE_NAME_CORE ls_std_core)
  15. set(MODULE_NAME_ENCODING ls_std_encoding)
  16. set(MODULE_NAME_EVENT ls_std_event)
  17. set(MODULE_NAME_IO ls_std_io)
  18. set(MODULE_NAME_NETWORK ls_std_network)
  19. set(MODULE_NAME_TIME ls_std_time)
  20. set(GOOGLE_TEST_MODULE googletest-1.11.0)
  21. ##########################################################
  22. # Options
  23. ##########################################################
  24. option(LS_STD_BUILD_WITH_TESTS "Build project with unit tests..." OFF)
  25. option(LS_STD_BUILD_WITH_IT "Build project with integration tests..." OFF)
  26. option(LS_STD_BUILD_WITH_SUPPORTED_COMPILER "Build project with supported compiler only..." ON)
  27. option(LS_STD_BUILD_STATIC "Build ls_std static library..." ON)
  28. option(LS_STD_BUILD_SHARED "Build ls_std shared library..." OFF)
  29. option(LS_STD_BUILD_MODULE "Build ls_std module library..." OFF)
  30. set(TARGET_COUNTER 0)
  31. if (${LS_STD_BUILD_STATIC})
  32. math(EXPR TARGET_COUNTER "${TARGET_COUNTER} + 1")
  33. set(GOAL "static library")
  34. endif ()
  35. if (${LS_STD_BUILD_SHARED})
  36. math(EXPR TARGET_COUNTER "${TARGET_COUNTER} + 1")
  37. set(GOAL "shared library")
  38. endif ()
  39. if (${LS_STD_BUILD_MODULE})
  40. math(EXPR TARGET_COUNTER "${TARGET_COUNTER} + 1")
  41. set(GOAL "module library")
  42. endif ()
  43. message("${PROJECT_NAME}: [Goal] ${GOAL}")
  44. if (TARGET_COUNTER GREATER 1)
  45. message("${PROJECT_NAME}: [Error] only one goal supported at the same time!")
  46. return()
  47. endif ()
  48. if (TARGET_COUNTER EQUAL 0)
  49. message("${PROJECT_NAME}: [Error] no goal selected!")
  50. return()
  51. endif ()
  52. ##########################################################
  53. # Compiler Settings
  54. ##########################################################
  55. message("${PROJECT_NAME}: Setting compiler flags...")
  56. set(CMAKE_CXX_STANDARD 17)
  57. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
  58. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  59. ##########################################################
  60. # Compiler Support
  61. ##########################################################
  62. if(${LS_STD_BUILD_WITH_SUPPORTED_COMPILER})
  63. message("${PROJECT_NAME}: build with compiler support...")
  64. # define supported compilers
  65. if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC OR
  66. ${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR
  67. ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang OR
  68. ${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
  69. message("${PROJECT_NAME}: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is supported...")
  70. else()
  71. message("${PROJECT_NAME}: [Error] ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is not supported... terminated!")
  72. return()
  73. endif ()
  74. # define which compilers are supported for shared or module goal
  75. if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC AND ${LS_STD_BUILD_MODULE})
  76. message("${PROJECT_NAME}: [Error] building \"${GOAL}\" with ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is not supported... terminated!")
  77. return()
  78. endif ()
  79. endif()
  80. # define which goals can run tests
  81. if (${LS_STD_BUILD_WITH_TESTS} AND ${LS_STD_BUILD_MODULE})
  82. message("${PROJECT_NAME}: [Error] building \"${GOAL}\" with tests is not supported... terminated!")
  83. return()
  84. endif ()
  85. ######################################################
  86. # Include Directories
  87. ######################################################
  88. message("${PROJECT_NAME}: Adding include directories...")
  89. if (${LS_STD_BUILD_WITH_TESTS} OR ${LS_STD_BUILD_WITH_IT})
  90. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/test)
  91. include_directories(${CMAKE_CURRENT_LIST_DIR}/test/lib/${GOOGLE_TEST_MODULE}/googletest/include)
  92. include_directories(${CMAKE_CURRENT_LIST_DIR}/test/lib/${GOOGLE_TEST_MODULE}/googlemock/include)
  93. endif ()
  94. include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
  95. ######################################################
  96. # Add Other CMake Dependencies
  97. ######################################################
  98. message("${PROJECT_NAME}: Adding additional cmake dependencies...")
  99. if (${LS_STD_BUILD_WITH_TESTS})
  100. add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/test/lib/${GOOGLE_TEST_MODULE})
  101. endif ()
  102. ####################################################################################################################
  103. ####################################################################################################################
  104. ####################################################################################################################
  105. # Source Files Modularization
  106. ####################################################################################################################
  107. ####################################################################################################################
  108. ####################################################################################################################
  109. set(SOURCE_FILES_BOXING
  110. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Boolean.cpp
  111. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Double.cpp
  112. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Float.cpp
  113. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Integer.cpp
  114. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/Long.cpp
  115. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/boxing/String.cpp)
  116. if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR
  117. ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang OR
  118. ${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
  119. set(SOURCE_FILES_CORE
  120. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/core/Class.cpp
  121. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/core/Version.cpp)
  122. endif()
  123. if (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
  124. set(SOURCE_FILES_CORE
  125. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/core/Class.cpp
  126. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/core/Version.cpp)
  127. endif()
  128. set(SOURCE_FILES_ENCODING
  129. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/encoding/Base64.cpp)
  130. set(SOURCE_FILES_EVENT
  131. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/event/serialization/SerializableJsonEvent.cpp
  132. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/event/Event.cpp
  133. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/event/EventHandler.cpp
  134. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/event/EventManager.cpp
  135. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/event/Narrator.cpp)
  136. set(SOURCE_FILES_IO
  137. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/kv/KvDocument.cpp
  138. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/kv/KvFileReader.cpp
  139. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/kv/KvPair.cpp
  140. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/kv/KvParser.cpp
  141. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/logging/Logger.cpp
  142. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/logging/LogLevel.cpp
  143. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XmlAttribute.cpp
  144. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XmlDeclaration.cpp
  145. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XmlDocument.cpp
  146. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XmlNode.cpp
  147. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XmlParser.cpp
  148. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/xml/XmlReader.cpp
  149. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/File.cpp
  150. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FileOutputStream.cpp
  151. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FileReader.cpp
  152. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/FileWriter.cpp
  153. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/StandardOutputWriter.cpp
  154. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/io/StorableFile.cpp)
  155. if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU OR
  156. ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang OR
  157. ${CMAKE_CXX_COMPILER_ID} STREQUAL AppleClang)
  158. set(SOURCE_FILES_NETWORK
  159. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/common/api/io/PosixReader.cpp
  160. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/common/api/io/PosixWriter.cpp
  161. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/common/api/socket/PosixSocket.cpp
  162. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/common/interface/IPosixReader.cpp
  163. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/common/interface/IPosixSocket.cpp
  164. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/common/interface/IPosixWriter.cpp
  165. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/network/core/ProtocolFamilyMapper.cpp
  166. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/network/core/ProtocolMapper.cpp
  167. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/network/socket/Socket.cpp
  168. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/network/socket/SocketAddressMapper.cpp)
  169. endif()
  170. set(SOURCE_FILES_TIME
  171. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/time/Date.cpp)
  172. ####################################################################################################################
  173. ####################################################################################################################
  174. ####################################################################################################################
  175. # Unit Test Files Modularization
  176. ####################################################################################################################
  177. ####################################################################################################################
  178. ####################################################################################################################
  179. if (${LS_STD_BUILD_WITH_TESTS})
  180. set(TEST_FILES_BOXING
  181. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/BooleanTest.cpp
  182. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/DoubleTest.cpp
  183. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/FloatTest.cpp
  184. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/IntegerTest.cpp
  185. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/LongTest.cpp
  186. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/boxing/StringTest.cpp)
  187. set(TEST_FILES_CORE
  188. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/EventNotHandledExceptionTest.cpp
  189. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/EventNotSubscribedExceptionTest.cpp
  190. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/FileNotFoundExceptionTest.cpp
  191. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/FileOperationExceptionTest.cpp
  192. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/IllegalArgumentExceptionTest.cpp
  193. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/IllegalArithmeticOperationExceptionTest.cpp
  194. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/IncompleteJsonExceptionTest.cpp
  195. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/NullPointerExceptionTest.cpp
  196. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/WrongProtocolExceptionTest.cpp
  197. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/exception/SocketOperationFailedExceptionTest.cpp
  198. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/utils/RegexUtilsTest.cpp
  199. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/utils/STLUtilsTest.cpp
  200. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/ClassTest.cpp
  201. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/LibraryVersionTest.cpp
  202. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/core/VersionTest.cpp)
  203. set(TEST_FILES_ENCODING
  204. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/encoding/Base64Test.cpp)
  205. set(TEST_FILES_EVENT
  206. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/event/serialization/SerializableJsonEventTest.cpp
  207. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/event/EventHandlerTest.cpp
  208. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/event/EventManagerTest.cpp
  209. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/event/EventTest.cpp
  210. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/event/NarratorTest.cpp
  211. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/event/Colour.cpp
  212. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/event/DailyNewsAgency.cpp
  213. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/event/GossipNewsAgency.cpp
  214. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/event/GossipNewsEvent.cpp
  215. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/event/NewsAgency.cpp
  216. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/event/SeriousNewsEvent.cpp
  217. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/event/TestDataCar.cpp
  218. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/event/TestDataMercedesCar.cpp)
  219. set(TEST_FILES_IO
  220. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/kv/KvDocumentTest.cpp
  221. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/kv/KvFileReaderTest.cpp
  222. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/kv/KvPairTest.cpp
  223. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/kv/KvParserTest.cpp
  224. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/logging/LoggerTest.cpp
  225. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/logging/LogLevelTest.cpp
  226. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XmlAttributeTest.cpp
  227. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XmlDeclarationTest.cpp
  228. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XmlDocumentTest.cpp
  229. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XmlNodeTest.cpp
  230. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XmlParserTest.cpp
  231. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XmlParserTestWrapperTest.cpp
  232. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/xml/XmlReaderTest.cpp
  233. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/FileOutputStreamTest.cpp
  234. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/FileReaderTest.cpp
  235. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/FileTest.cpp
  236. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/FileWriterTest.cpp
  237. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/StandardOutputWriterTest.cpp
  238. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/io/StorableFileTest.cpp
  239. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/io/xml/TestDataFactory.cpp
  240. ${CMAKE_CURRENT_SOURCE_DIR}/test/classes/io/xml/XmlParserTestWrapper.cpp)
  241. set(TEST_FILES_NETWORK
  242. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/network/core/ProtocolFamilyMapperTest.cpp
  243. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/network/core/ProtocolMapperTest.cpp
  244. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/network/socket/SocketAddressMapperTest.cpp
  245. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/network/socket/SocketTest.cpp)
  246. set(TEST_FILES_SERIALIZATION
  247. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/serialization/JsonTest.cpp)
  248. set(TEST_FILES_TIME
  249. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/time/DateTest.cpp)
  250. endif ()
  251. ####################################################################################################################
  252. ####################################################################################################################
  253. ####################################################################################################################
  254. # Unit Test Suite Builds
  255. ####################################################################################################################
  256. ####################################################################################################################
  257. ####################################################################################################################
  258. ##########################################################
  259. # Build Unit Tests (boxing)
  260. ##########################################################
  261. if (${LS_STD_BUILD_WITH_TESTS})
  262. message("${MODULE_NAME_BOXING}: Building tests...")
  263. add_executable(${MODULE_NAME_BOXING}_test ${TEST_FILES_BOXING})
  264. endif ()
  265. ##########################################################
  266. # Build Unit Tests (core)
  267. ##########################################################
  268. if (${LS_STD_BUILD_WITH_TESTS})
  269. message("${MODULE_NAME_CORE}: Building tests...")
  270. add_executable(${MODULE_NAME_CORE}_test ${TEST_FILES_CORE})
  271. endif ()
  272. ##########################################################
  273. # Build Unit Tests (encoding)
  274. ##########################################################
  275. if (${LS_STD_BUILD_WITH_TESTS})
  276. message("${MODULE_NAME_ENCODING}: Building tests...")
  277. add_executable(${MODULE_NAME_ENCODING}_test ${TEST_FILES_ENCODING})
  278. endif ()
  279. ##########################################################
  280. # Build Unit Tests (event)
  281. ##########################################################
  282. if (${LS_STD_BUILD_WITH_TESTS})
  283. message("${MODULE_NAME_EVENT}: Building tests...")
  284. add_executable(${MODULE_NAME_EVENT}_test ${TEST_FILES_EVENT})
  285. endif ()
  286. ##########################################################
  287. # Build Unit Tests (io)
  288. ##########################################################
  289. if (${LS_STD_BUILD_WITH_TESTS})
  290. message("${MODULE_NAME_IO}: Building tests...")
  291. add_executable(${MODULE_NAME_IO}_test ${TEST_FILES_IO})
  292. endif ()
  293. ##########################################################
  294. # Build Unit Tests (network)
  295. ##########################################################
  296. if (${LS_STD_BUILD_WITH_TESTS})
  297. message("${MODULE_NAME_NETWORK}: Building tests...")
  298. add_executable(${MODULE_NAME_NETWORK}_test ${TEST_FILES_NETWORK})
  299. endif ()
  300. ##########################################################
  301. # Build Unit Tests (time)
  302. ##########################################################
  303. if (${LS_STD_BUILD_WITH_TESTS})
  304. message("${MODULE_NAME_TIME}: Building tests...")
  305. add_executable(${MODULE_NAME_TIME}_test ${TEST_FILES_TIME})
  306. endif ()
  307. ##########################################################
  308. # Build Unit Tests (all)
  309. ##########################################################
  310. if (${LS_STD_BUILD_WITH_TESTS})
  311. message("${PROJECT_NAME}: Building tests...")
  312. add_executable(${PROJECT_NAME}_test
  313. ${TEST_FILES_BOXING}
  314. ${TEST_FILES_CORE}
  315. ${TEST_FILES_ENCODING}
  316. ${TEST_FILES_EVENT}
  317. ${TEST_FILES_IO}
  318. ${TEST_FILES_NETWORK}
  319. ${TEST_FILES_SERIALIZATION}
  320. ${TEST_FILES_TIME})
  321. endif ()
  322. ####################################################################################################################
  323. ####################################################################################################################
  324. ####################################################################################################################
  325. # Integration Test Files Modularization
  326. ####################################################################################################################
  327. ####################################################################################################################
  328. ####################################################################################################################
  329. if (${LS_STD_BUILD_WITH_IT})
  330. set(IT_FILES_NETWORK
  331. ${CMAKE_CURRENT_SOURCE_DIR}/test/cases/network/socket/SocketIT.cpp)
  332. endif()
  333. ####################################################################################################################
  334. ####################################################################################################################
  335. ####################################################################################################################
  336. # Integration Test Suite Builds
  337. ####################################################################################################################
  338. ####################################################################################################################
  339. ####################################################################################################################
  340. ##########################################################
  341. # Build Integration Tests (network)
  342. ##########################################################
  343. if (${LS_STD_BUILD_WITH_IT})
  344. message("${MODULE_NAME_NETWORK}: Building integration tests...")
  345. add_executable(${MODULE_NAME_NETWORK}_it ${IT_FILES_NETWORK})
  346. endif ()
  347. ####################################################################################################################
  348. ####################################################################################################################
  349. ####################################################################################################################
  350. # Build Library Binaries
  351. ####################################################################################################################
  352. ####################################################################################################################
  353. ####################################################################################################################
  354. ##########################################################
  355. # Build Library (boxing)
  356. ##########################################################
  357. message("${PROJECT_NAME}: Building ${MODULE_NAME_BOXING} library version ${PROJECT_VERSION}...")
  358. if (${LS_STD_BUILD_STATIC})
  359. add_library("${MODULE_NAME_BOXING}" STATIC ${SOURCE_FILES_BOXING})
  360. set_target_properties("${MODULE_NAME_BOXING}" PROPERTIES DEBUG_POSTFIX "_d")
  361. endif ()
  362. if (${LS_STD_BUILD_SHARED})
  363. add_library("${MODULE_NAME_BOXING}" SHARED ${SOURCE_FILES_BOXING})
  364. target_link_libraries("${MODULE_NAME_BOXING}" ${MODULE_NAME_CORE})
  365. set_target_properties("${MODULE_NAME_BOXING}" PROPERTIES DEBUG_POSTFIX "_d")
  366. endif ()
  367. if (${LS_STD_BUILD_MODULE})
  368. add_library("${MODULE_NAME_BOXING}" MODULE ${SOURCE_FILES_BOXING})
  369. set_target_properties("${MODULE_NAME_BOXING}" PROPERTIES DEBUG_POSTFIX "_d")
  370. endif ()
  371. ##########################################################
  372. # Build Library (core)
  373. ##########################################################
  374. message("${PROJECT_NAME}: Building ${MODULE_NAME_CORE} library version ${PROJECT_VERSION}...")
  375. if (${LS_STD_BUILD_STATIC})
  376. add_library("${MODULE_NAME_CORE}" STATIC ${SOURCE_FILES_CORE})
  377. set_target_properties("${MODULE_NAME_CORE}" PROPERTIES DEBUG_POSTFIX "_d")
  378. endif ()
  379. if (${LS_STD_BUILD_SHARED})
  380. add_library("${MODULE_NAME_CORE}" SHARED ${SOURCE_FILES_CORE})
  381. set_target_properties("${MODULE_NAME_CORE}" PROPERTIES DEBUG_POSTFIX "_d")
  382. endif ()
  383. if (${LS_STD_BUILD_MODULE})
  384. add_library("${MODULE_NAME_CORE}" MODULE ${SOURCE_FILES_CORE})
  385. set_target_properties("${MODULE_NAME_CORE}" PROPERTIES DEBUG_POSTFIX "_d")
  386. endif ()
  387. ##########################################################
  388. # Build Library (encoding)
  389. ##########################################################
  390. message("${PROJECT_NAME}: Building ${MODULE_NAME_ENCODING} library version ${PROJECT_VERSION}...")
  391. if (${LS_STD_BUILD_STATIC})
  392. add_library("${MODULE_NAME_ENCODING}" STATIC ${SOURCE_FILES_ENCODING})
  393. set_target_properties("${MODULE_NAME_ENCODING}" PROPERTIES DEBUG_POSTFIX "_d")
  394. endif ()
  395. if (${LS_STD_BUILD_SHARED})
  396. add_library("${MODULE_NAME_ENCODING}" SHARED ${SOURCE_FILES_ENCODING})
  397. set_target_properties("${MODULE_NAME_ENCODING}" PROPERTIES DEBUG_POSTFIX "_d")
  398. endif ()
  399. if (${LS_STD_BUILD_MODULE})
  400. add_library("${MODULE_NAME_ENCODING}" MODULE ${SOURCE_FILES_ENCODING})
  401. set_target_properties("${MODULE_NAME_ENCODING}" PROPERTIES DEBUG_POSTFIX "_d")
  402. endif ()
  403. # CLI base64
  404. add_executable(cli_base64
  405. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/encoding/cli/cli_base64_main.cpp
  406. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/encoding/Base64.cpp
  407. ${CMAKE_CURRENT_SOURCE_DIR}/source/ls_std/core/Version.cpp)
  408. ##########################################################
  409. # Build Library (event)
  410. ##########################################################
  411. message("${PROJECT_NAME}: Building ${MODULE_NAME_EVENT} library version ${PROJECT_VERSION}...")
  412. if (${LS_STD_BUILD_STATIC})
  413. add_library("${MODULE_NAME_EVENT}" STATIC ${SOURCE_FILES_EVENT})
  414. set_target_properties("${MODULE_NAME_EVENT}" PROPERTIES DEBUG_POSTFIX "_d")
  415. endif ()
  416. if (${LS_STD_BUILD_SHARED})
  417. add_library("${MODULE_NAME_EVENT}" SHARED ${SOURCE_FILES_EVENT})
  418. target_link_libraries("${MODULE_NAME_EVENT}" ${MODULE_NAME_CORE})
  419. set_target_properties("${MODULE_NAME_EVENT}" PROPERTIES DEBUG_POSTFIX "_d")
  420. endif ()
  421. if (${LS_STD_BUILD_MODULE})
  422. add_library("${MODULE_NAME_EVENT}" MODULE ${SOURCE_FILES_EVENT})
  423. set_target_properties("${MODULE_NAME_EVENT}" PROPERTIES DEBUG_POSTFIX "_d")
  424. endif ()
  425. ##########################################################
  426. # Build Library (io)
  427. ##########################################################
  428. message("${PROJECT_NAME}: Building ${MODULE_NAME_IO} library version ${PROJECT_VERSION}...")
  429. if (${LS_STD_BUILD_STATIC})
  430. add_library("${MODULE_NAME_IO}" STATIC ${SOURCE_FILES_IO})
  431. set_target_properties("${MODULE_NAME_IO}" PROPERTIES DEBUG_POSTFIX "_d")
  432. endif ()
  433. if (${LS_STD_BUILD_SHARED})
  434. add_library("${MODULE_NAME_IO}" SHARED ${SOURCE_FILES_IO})
  435. target_link_libraries("${MODULE_NAME_IO}" ${MODULE_NAME_CORE})
  436. set_target_properties("${MODULE_NAME_IO}" PROPERTIES DEBUG_POSTFIX "_d")
  437. endif ()
  438. if (${LS_STD_BUILD_MODULE})
  439. add_library("${MODULE_NAME_IO}" MODULE ${SOURCE_FILES_IO})
  440. set_target_properties("${MODULE_NAME_IO}" PROPERTIES DEBUG_POSTFIX "_d")
  441. endif ()
  442. ##########################################################
  443. # Build Library (network)
  444. ##########################################################
  445. message("${PROJECT_NAME}: Building ${MODULE_NAME_NETWORK} library version ${PROJECT_VERSION}...")
  446. if (${LS_STD_BUILD_STATIC})
  447. add_library("${MODULE_NAME_NETWORK}" STATIC ${SOURCE_FILES_NETWORK})
  448. set_target_properties("${MODULE_NAME_NETWORK}" PROPERTIES DEBUG_POSTFIX "_d")
  449. endif ()
  450. if (${LS_STD_BUILD_SHARED})
  451. add_library("${MODULE_NAME_NETWORK}" SHARED ${SOURCE_FILES_NETWORK})
  452. target_link_libraries("${MODULE_NAME_NETWORK}" ${MODULE_NAME_CORE})
  453. set_target_properties("${MODULE_NAME_NETWORK}" PROPERTIES DEBUG_POSTFIX "_d")
  454. endif ()
  455. if (${LS_STD_BUILD_MODULE})
  456. add_library("${MODULE_NAME_NETWORK}" MODULE ${SOURCE_FILES_NETWORK})
  457. set_target_properties("${MODULE_NAME_NETWORK}" PROPERTIES DEBUG_POSTFIX "_d")
  458. endif ()
  459. ##########################################################
  460. # Build Library (time)
  461. ##########################################################
  462. message("${PROJECT_NAME}: Building ${MODULE_NAME_TIME} library version ${PROJECT_VERSION}...")
  463. if (${LS_STD_BUILD_STATIC})
  464. add_library("${MODULE_NAME_TIME}" STATIC ${SOURCE_FILES_TIME})
  465. set_target_properties("${MODULE_NAME_TIME}" PROPERTIES DEBUG_POSTFIX "_d")
  466. endif ()
  467. if (${LS_STD_BUILD_SHARED})
  468. add_library("${MODULE_NAME_TIME}" SHARED ${SOURCE_FILES_TIME})
  469. target_link_libraries("${MODULE_NAME_TIME}" ${MODULE_NAME_CORE})
  470. set_target_properties("${MODULE_NAME_TIME}" PROPERTIES DEBUG_POSTFIX "_d")
  471. endif ()
  472. if (${LS_STD_BUILD_MODULE})
  473. add_library("${MODULE_NAME_TIME}" MODULE ${SOURCE_FILES_TIME})
  474. set_target_properties("${MODULE_NAME_TIME}" PROPERTIES DEBUG_POSTFIX "_d")
  475. endif ()
  476. ####################################################################################################################
  477. ####################################################################################################################
  478. ####################################################################################################################
  479. # Unit Test Suite: Linking
  480. ####################################################################################################################
  481. ####################################################################################################################
  482. ####################################################################################################################
  483. ##########################################################
  484. # Linking (boxing)
  485. ##########################################################
  486. if (${LS_STD_BUILD_WITH_TESTS})
  487. message("${MODULE_NAME_BOXING}: Linking libraries for test application...")
  488. target_link_libraries(${MODULE_NAME_BOXING}_test
  489. gtest
  490. gmock
  491. gtest_main
  492. "${MODULE_NAME_BOXING}"
  493. "${MODULE_NAME_CORE}")
  494. endif ()
  495. ##########################################################
  496. # Linking (core)
  497. ##########################################################
  498. if (${LS_STD_BUILD_WITH_TESTS})
  499. message("${MODULE_NAME_CORE}: Linking libraries for test application...")
  500. target_link_libraries(${MODULE_NAME_CORE}_test
  501. gtest
  502. gmock
  503. gtest_main
  504. "${MODULE_NAME_CORE}")
  505. endif ()
  506. ##########################################################
  507. # Linking (encoding)
  508. ##########################################################
  509. if (${LS_STD_BUILD_WITH_TESTS})
  510. message("${MODULE_NAME_ENCODING}: Linking libraries for test application...")
  511. target_link_libraries(${MODULE_NAME_ENCODING}_test
  512. gtest
  513. gmock
  514. gtest_main
  515. "${MODULE_NAME_ENCODING}"
  516. "${MODULE_NAME_CORE}")
  517. endif ()
  518. ##########################################################
  519. # Linking (event)
  520. ##########################################################
  521. if (${LS_STD_BUILD_WITH_TESTS})
  522. message("${MODULE_NAME_EVENT}: Linking libraries for test application...")
  523. target_link_libraries(${MODULE_NAME_EVENT}_test
  524. gtest
  525. gmock
  526. gtest_main
  527. "${MODULE_NAME_EVENT}"
  528. "${MODULE_NAME_CORE}")
  529. endif ()
  530. ##########################################################
  531. # Linking (io)
  532. ##########################################################
  533. if (${LS_STD_BUILD_WITH_TESTS})
  534. message("${MODULE_NAME_IO}: Linking libraries for test application...")
  535. target_link_libraries(${MODULE_NAME_IO}_test
  536. gtest
  537. gmock
  538. gtest_main
  539. "${MODULE_NAME_IO}"
  540. "${MODULE_NAME_CORE}")
  541. endif ()
  542. ##########################################################
  543. # Linking (network)
  544. ##########################################################
  545. if (${LS_STD_BUILD_WITH_TESTS})
  546. message("${MODULE_NAME_NETWORK}: Linking libraries for test application...")
  547. target_link_libraries(${MODULE_NAME_NETWORK}_test
  548. gtest
  549. gmock
  550. gtest_main
  551. "${MODULE_NAME_NETWORK}"
  552. "${MODULE_NAME_CORE}")
  553. endif ()
  554. ##########################################################
  555. # Linking (time)
  556. ##########################################################
  557. if (${LS_STD_BUILD_WITH_TESTS})
  558. message("${MODULE_NAME_TIME}: Linking libraries for test application...")
  559. target_link_libraries(${MODULE_NAME_TIME}_test
  560. gtest
  561. gmock
  562. gtest_main
  563. "${MODULE_NAME_TIME}"
  564. "${MODULE_NAME_CORE}")
  565. endif ()
  566. ##########################################################
  567. # Linking (all)
  568. ##########################################################
  569. if (${LS_STD_BUILD_WITH_TESTS})
  570. message("${PROJECT_NAME}: Linking libraries for test application...")
  571. target_link_libraries(${PROJECT_NAME}_test
  572. gtest
  573. gmock
  574. gtest_main
  575. "${MODULE_NAME_CORE}"
  576. "${MODULE_NAME_BOXING}"
  577. "${MODULE_NAME_ENCODING}"
  578. "${MODULE_NAME_EVENT}"
  579. "${MODULE_NAME_IO}"
  580. "${MODULE_NAME_NETWORK}"
  581. "${MODULE_NAME_TIME}")
  582. endif ()
  583. ####################################################################################################################
  584. ####################################################################################################################
  585. ####################################################################################################################
  586. # Integration Test Suite: Linking
  587. ####################################################################################################################
  588. ####################################################################################################################
  589. ####################################################################################################################
  590. ##########################################################
  591. # Linking (network)
  592. ##########################################################
  593. if (${LS_STD_BUILD_WITH_IT})
  594. message("${MODULE_NAME_NETWORK}: Linking libraries for integration test application...")
  595. target_link_libraries(${MODULE_NAME_NETWORK}_it
  596. gtest
  597. gmock
  598. gtest_main
  599. "${MODULE_NAME_NETWORK}"
  600. "${MODULE_NAME_CORE}")
  601. endif ()