[CMake] Overloading the install make rule

Dixon, Shane Shane.Dixon at atmel.com
Fri Oct 9 11:07:43 EDT 2009


Eric, 

That might work.  The catch is that the difference isn't in the executable, but in the .dll that gets installed with it.  I have a cryptoki-hw.dll and a cryptoki-sw.dll.  Since Windows doesn't allow me to use RPATH at all, at runtime it runs whatever .dll is sitting in the same folder as the .exe.  I might be able to do as you suggest and move the two .exe's into two different folders to keep the .dll's separate.

--
Shane Dixon
Linux Engineer
Atmel Corporation 


-----Original Message-----
From: Eric Noulard [mailto:eric.noulard at gmail.com] 
Sent: Friday, October 09, 2009 12:51 AM
To: Dixon, Shane
Cc: cmake at cmake.org
Subject: Re: [CMake] Overloading the install make rule

2009/10/8 Dixon, Shane <Shane.Dixon at atmel.com>:
> I have two different version of my program: one that runs in simulation mode, and the other that runs in "real" mode.  Right now I just select which I want using an option -DEMULATION_MODE=ON or -DEMULATION_MODE=OFF.  The flag is checked later and generates an installer (NSIS) that has -emul or -real at the end so I know which I'm installing.
>
> My question is whether I can overload the install target to "install/real" and "install/emul" with "install" just pointing to emul as a safe default.
>
> Additionally I'd like to be able to setup NSIS so that when I install, I can select which version is installed at runtime there.
>
> Is all or any of this possible?

May be you can just generate 2 differents executables from the same source:
 yourprog-emul
 yourprog-real

This can be done easily using something like:

add_executable(yourprog-emul ${SOURCE})
target_link_libraries(yourprog-emul ${LIBS}) set_target_properties(yourprog-emul PROPERTIES COMPILE_FLAGS
"-DEMULATION_MODE=ON")


add_executable(yourprog-real ${SOURCE})
target_link_libraries(yourprog-real ${LIBS}) set_target_properties(yourprog-real PROPERTIES COMPILE_FLAGS
"-DEMULATION_MODE=OFF")

then you install both target using COMPONENT install(target yourprog-real DESTINATION <dest>
         COMPONENT  RealMode)

install(target yourprog-emul DESTINATION <dest>
         COMPONENT  EmulMode)

Since you are using NSIS, you should be able to select component from the NSIS installer at install time, see:
http://www.itk.org/Wiki/CMake:Component_Install_With_CPack

--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org


More information about the CMake mailing list