IF(NOT WIN32)
  EXECUTE_PROCESS(
    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/configure
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  )
ENDIF(NOT WIN32)

SET(ONIG_INCLUDE_DIRS
  ${CMAKE_CURRENT_SOURCE_DIR}/
  ${CMAKE_CURRENT_SOURCE_DIR}/enc/unicode
  PARENT_SCOPE
)

SET(ONIG_SOURCES
           ${CMAKE_CURRENT_SOURCE_DIR}/regcomp.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regenc.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regerror.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regexec.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regext.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/reggnu.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regparse.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regposerr.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regposix.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regsyntax.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regtrav.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/regversion.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/st.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/ascii.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/big5.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/cp949.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/emacs_mule.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/euc_jp.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/euc_kr.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/euc_tw.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/gb18030.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/gbk.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_1.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_10.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_11.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_13.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_14.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_15.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_16.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_2.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_3.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_4.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_5.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_6.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_7.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_8.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/iso_8859_9.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/koi8_r.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/koi8_u.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/shift_jis.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/unicode.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/us_ascii.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/utf_16be.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/utf_16le.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/utf_32be.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/utf_32le.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/utf_8.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/windows_1250.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/windows_1251.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/windows_1252.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/windows_1253.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/windows_1254.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/windows_1257.c 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/windows_31j.c
           PARENT_SCOPE
)

SET(ONIG_HEADERS
           ${CMAKE_CURRENT_SOURCE_DIR}/config.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/enc/unicode/casefold.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/onigmo.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/onigmognu.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/onigmoposix.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/regenc.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/regint.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/regparse.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/st.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/win32/config.h 
           ${CMAKE_CURRENT_SOURCE_DIR}/config-onig-edbee.h
           PARENT_SCOPE
)
