CMakeLists.txt 622 B

12345678910111213141516
  1. set(LIBRARY_NAME error_code)
  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. if (OPTION_ENABLE_TEST_CODE)
  6. set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
  7. set(LIBRARY_TEST_SOURCE_LIST
  8. ${CMAKE_CURRENT_LIST_DIR}/test.h
  9. ${CMAKE_CURRENT_LIST_DIR}/test.cpp
  10. ${CMAKE_CURRENT_LIST_DIR}/error_code.cpp
  11. )
  12. add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
  13. target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
  14. endif ()