ctkMacroAddCtkLibraryOptions.cmake 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #
  2. #
  3. #
  4. MACRO(ctkMacroAddCtkLibraryOptions lib)
  5. SET(filepath ${CMAKE_CURRENT_SOURCE_DIR}/Libs/${lib}/ctk_library_options.cmake)
  6. # Add options only if "ctk_library_option.cmake" file exists
  7. IF(EXISTS ${filepath})
  8. # Make sure the variable is cleared
  9. SET(ctk_library_options )
  10. INCLUDE(${filepath})
  11. FOREACH(option ${ctk_library_options})
  12. # Make sure option is correctly formated
  13. IF(NOT "${option}" MATCHES "^[A-Za-z0-9]+:(ON|OFF)")
  14. MESSAGE(FATAL_ERROR "In ${filepath}, option ${option} is incorrect. Options should be specified using the following format OPT1:[ON|OFF]. For example OPT1:OFF or OPT2:ON")
  15. ENDIF()
  16. # Extract option name and option default value
  17. STRING(REPLACE ":" "\\;" option ${option})
  18. SET(optionlist ${option})
  19. LIST(GET optionlist 0 option_name)
  20. LIST(GET optionlist 1 option_value)
  21. OPTION(CTK_LIB_${lib}_${option_name} "Enable ${lib} Library ${option_name} option." ${option_value})
  22. ENDFOREACH()
  23. ENDIF()
  24. ENDMACRO()