CMakeLists.txt 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. set(LIBRARY_NAME zxthread)
  2. unset(OPTION_ENABLE_TEST_CODE CACHE)
  3. option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
  4. message("<=${LIBRARY_NAME}=> OPTION_ENABLE_TEST_CODE: " ${OPTION_ENABLE_TEST_CODE})
  5. set(LIBRARY_SOURCE_LIST
  6. ${CMAKE_CURRENT_LIST_DIR}/thread_condition.h
  7. ${CMAKE_CURRENT_LIST_DIR}/thread_condition.cpp
  8. ${CMAKE_CURRENT_LIST_DIR}/time_tool.h
  9. ${CMAKE_CURRENT_LIST_DIR}/time_tool.cpp
  10. ${CMAKE_CURRENT_LIST_DIR}/binary_buf.h
  11. ${CMAKE_CURRENT_LIST_DIR}/binary_buf.cpp
  12. )
  13. set(LIBRARY_DEPEND_LIST
  14. -lpthread
  15. )
  16. add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
  17. target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
  18. if (OPTION_ENABLE_TEST_CODE)
  19. set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
  20. set(LIBRARY_TEST_SOURCE_LIST
  21. ${CMAKE_CURRENT_LIST_DIR}/test.h
  22. ${CMAKE_CURRENT_LIST_DIR}/test.cpp
  23. )
  24. add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
  25. target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
  26. endif ()