project( pinentry-qt4 ) 
# Always include srcdir and builddir in include path
# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
# about every subdir since cmake 2.4.0
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# These definitions make Qt binary incompatible, but it is strongly
# suggested to link against a static Qt compiled with at least these
# options set:
#add_definitions( -DQT_NO_CONTEXTMENU -DQT_NO_COMPLETER -DQT_NO_DRAGANDDROP -DQT_NO_CLIPBOARD -DQT_NO_VALIDATOR -DQT_NO_STYLE_STYLESHEET )

# put the include dirs which are in the source or build tree
# before all other include dirs, so the headers in the sources
# are prefered over the already installed ones
# since cmake 2.4.1
set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)

find_package(Qt4 REQUIRED)

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/assuan
    ${CMAKE_CURRENT_SOURCE_DIR}/secmem
    ${CMAKE_CURRENT_SOURCE_DIR}/pinentry
    ${QT_INCLUDES}
)

set( pinentry-qt4_SRCS
     assuan/assuan-util.c
     assuan/assuan-errors.c
     assuan/assuan-buffer.c
     assuan/assuan-handler.c
     assuan/assuan-listen.c
     assuan/assuan-pipe-server.c
     pinentry/pinentry.c
     qt4/main.cpp
     qt4/qsecurelineedit.cpp
     qt4/pinentrydialog.cpp
     qt4/secstring.cpp
     secmem/secmem.c
     secmem/util.c
)

qt4_automoc( ${pinentry-qt4_SRCS} )

add_executable( pinentry-qt4 ${pinentry-qt4_SRCS} )
target_link_libraries( pinentry-qt4 ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} )
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/pinentry-qt4 DESTINATION bin )
