How to use a if condition while using INSTALL in cmake?

779 Views Asked by At

I am trying copy certain dll's to Output folder where the generated binary resides and some of the dll's are visual studio version specific. I tried something similar to below template but it gives me errors.

INSTALL(FILES 
    ../x.dll
    ../y.dll
    ../z.dll
    IF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 12 2013")
        ../xyz.dll          
    ELSE()
        ../xy.dll
    ENDIF()
    DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/Release)

Where am i going wrong? (I am new to CMAKE)

1

There are 1 best solutions below

0
On

I solved my issue with below template.

IF(${CMAKE_GENERATOR} STREQUAL "Visual Studio 12 2013")
    SET (VS_DEPENDENT_DLL ../xyz.dll) 
ELSE()
    SET (VS_DEPENDENT_DLL ../xy.dll)
ENDIF()

INSTALL(FILES 
    ../x.dll
    ../y.dll
    ../z.dll
    ${VS_DEPENDENT_DLL}
    DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/Release)