[CMake] change add_executable to add_library leads to an error

Cedric Doucet cedric.doucet at inria.fr
Wed Dec 23 08:26:38 EST 2015


Hello, 

I have the following script: 
================================= 


file(GLOB_RECURSE statphys "*.cpp") 




#add_library(simol-statphys SHARED ${statphys}) 
add_executable(simol-statphys ${statphys}) 




add_dependencies(simol-statphys simol-core) 


add_custom_target(statphys simol-statphys) 




target_link_libraries(simol-statphys simol-core) 

target_link_libraries(simol-statphys ${ARMADILLO_INSTALL_DIR}/lib/libarmadillo.so) 
target_link_libraries(simol-statphys ${YAMLCPP_INSTALL_DIR}/lib/libyaml-cpp.a) 

================================= 




I would like generate a shared library simol-statphys instead of an executable simol-statphys. 

In other words, I would like to replace the call to add_executable, to the one which is contained in the comment below this call. 




However, if I do this, and I type 




make statphys 




I get the following error message: 




Scanning dependencies of target statphys 
/bin/sh: 1: simol-statphys: not found 
make[3]: *** [src/modules/statphys/CMakeFiles/statphys] Erreur 127 
make[2]: *** [src/modules/statphys/CMakeFiles/statphys.dir/all] Erreur 2 
make[1]: *** [src/modules/statphys/CMakeFiles/statphys.dir/rule] Erreur 2 
make: *** [statphys] Erreur 2 




Does someone can explain me where do the problem come from? 




Cédric 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151223/9b1a8686/attachment-0001.html>


More information about the CMake mailing list