CMakeLists.txt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #-------------------------------------------------------------------------------------------
  2. # Copyright (C) Electronic Arts Inc. All rights reserved.
  3. #-------------------------------------------------------------------------------------------
  4. #-------------------------------------------------------------------------------------------
  5. # CMake info
  6. #-------------------------------------------------------------------------------------------
  7. cmake_minimum_required(VERSION 3.14)
  8. project(EAThreadTest CXX)
  9. include(CTest)
  10. #-------------------------------------------------------------------------------------------
  11. # Defines
  12. #-------------------------------------------------------------------------------------------
  13. add_definitions(-D_CRT_SECURE_NO_WARNINGS)
  14. add_definitions(-D_SCL_SECURE_NO_WARNINGS)
  15. add_definitions(-D_CHAR16T)
  16. add_definitions(-DEA_OPENSOURCE)
  17. #-------------------------------------------------------------------------------------------
  18. # Compiler Flags
  19. #-------------------------------------------------------------------------------------------
  20. include(CommonCppFlags)
  21. # Parts of the test suite fail to compile if char8_t is enabled, so we disable it
  22. if (EATHREAD_NO_CHAR8T_FLAG)
  23. add_compile_options(${EATHREAD_NO_CHAR8T_FLAG})
  24. endif()
  25. #-------------------------------------------------------------------------------------------
  26. # Source files
  27. #-------------------------------------------------------------------------------------------
  28. file(GLOB EATHREADTEST_SOURCES "thread/source/*.cpp")
  29. set(SOURCES ${EATHREADTEST_SOURCES})
  30. #-------------------------------------------------------------------------------------------
  31. # Executable definition
  32. #-------------------------------------------------------------------------------------------
  33. add_executable(EAThreadTest ${SOURCES})
  34. #-------------------------------------------------------------------------------------------
  35. # Include directories
  36. #-------------------------------------------------------------------------------------------
  37. target_include_directories(EAThreadTest PUBLIC include)
  38. #-------------------------------------------------------------------------------------------
  39. # Dependencies
  40. #-------------------------------------------------------------------------------------------
  41. FetchContent_Declare(
  42. EABase
  43. GIT_REPOSITORY https://github.com/electronicarts/EABase.git
  44. GIT_TAG 123363eb82e132c0181ac53e43226d8ee76dea12
  45. GIT_SUBMODULES "" # This should be temporary until we update the cyclic submodule dependencies in EABase.
  46. )
  47. FetchContent_MakeAvailable(EABase)
  48. target_link_libraries(EAThreadTest EABase)
  49. FetchContent_Declare(
  50. EAAssert
  51. GIT_REPOSITORY https://github.com/electronicarts/EAAssert.git
  52. GIT_TAG e5e181255de2e883dd1f987c78ccc42ac81d3bca
  53. GIT_SUBMODULES "" # This should be temporary until we update the cyclic submodule dependencies in EAAssert.
  54. )
  55. FetchContent_MakeAvailable(EAAssert)
  56. target_link_libraries(EAThreadTest EAAssert)
  57. FetchContent_Declare(
  58. EAStdC
  59. GIT_REPOSITORY https://github.com/electronicarts/EAStdC.git
  60. GIT_TAG fbcc34e89c63636054334888f3a5bd7ac2fd4b76
  61. GIT_SUBMODULES "" # This should be temporary until we update the cyclic submodule dependencies in EAStdC.
  62. )
  63. FetchContent_MakeAvailable(EAStdC)
  64. target_link_libraries(EAThreadTest EAStdC)
  65. FetchContent_Declare(
  66. EAMain
  67. GIT_REPOSITORY https://github.com/electronicarts/EAMain.git
  68. GIT_TAG 24ca8bf09e6b47b860286fc2f4c832f4009273d1
  69. GIT_SUBMODULES "" # This should be temporary until we update the cyclic submodule dependencies in EAMain.
  70. )
  71. FetchContent_MakeAvailable(EAMain)
  72. target_link_libraries(EAThreadTest EAMain)
  73. FetchContent_Declare(
  74. EATest
  75. GIT_REPOSITORY https://github.com/electronicarts/EATest.git
  76. GIT_TAG a59b372fc9cba517283ad6d060d2ab96e0ba34ac
  77. GIT_SUBMODULES "" # This should be temporary until we update the cyclic submodule dependencies in EATest.
  78. )
  79. FetchContent_MakeAvailable(EATest)
  80. target_link_libraries(EAThreadTest EATest)
  81. FetchContent_Declare(
  82. EASTL
  83. GIT_REPOSITORY https://github.com/electronicarts/EASTL.git
  84. GIT_TAG 7fadbf0da01e6f6e0e7038b1b34343a069b8fc51
  85. GIT_SUBMODULES "" # This should be temporary until we update the cyclic submodule dependencies in EASTL.
  86. )
  87. FetchContent_MakeAvailable(EASTL)
  88. target_link_libraries(EAThreadTest EASTL)
  89. target_link_libraries(EAThreadTest EAThread)
  90. set(THREADS_PREFER_PTHREAD_FLAG ON)
  91. find_package(Threads REQUIRED)
  92. if((NOT APPLE) AND (NOT WIN32))
  93. target_link_libraries(EAThreadTest ${EASTLTest_Libraries} Threads::Threads rt)
  94. else()
  95. target_link_libraries(EAThreadTest ${EASTLTest_Libraries} Threads::Threads)
  96. endif()
  97. #-------------------------------------------------------------------------------------------
  98. # Run Unit tests and verify the results.
  99. #-------------------------------------------------------------------------------------------
  100. add_test(EAThreadTestRuns EAThreadTest)
  101. set_tests_properties (EAThreadTestRuns PROPERTIES PASS_REGULAR_EXPRESSION "RETURNCODE=0")