INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})

ADD_CUSTOM_COMMAND(
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/license.c
    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/genstring.py
        license_msg
        ${CMAKE_CURRENT_BINARY_DIR}/license.c
        ${CMAKE_SOURCE_DIR}/COPYING
    MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/COPYING
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/genstring.py
    )

SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})

IF(BUILD_SHARED_LIBS)
    ADD_EXECUTABLE(yasm
        yasm.c
        yasm-options.c
        yasm-plugin.c
        )
    TARGET_LINK_LIBRARIES(yasm libyasm ${LIBDL})
ELSE(BUILD_SHARED_LIBS)
    ADD_EXECUTABLE(yasm
        yasm.c
        yasm-options.c
        )
    TARGET_LINK_LIBRARIES(yasm yasmstd libyasm)
ENDIF(BUILD_SHARED_LIBS)

SET_SOURCE_FILES_PROPERTIES(yasm.c PROPERTIES
    OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/license.c
    )

INSTALL(TARGETS yasm RUNTIME DESTINATION bin)
