Maybe there's a better way to get that property name, I don't know. Obviously IMPORTED_LOCATION_RELEASE can have variants depending on how the shared library was built / installed. It works great using g++ or clang, but MSVC (Visual Studio 2017) creates a Debug or Release directory. That is, it configures the project for several configurations at once.Because of that, when using such generators the variable CMAKEBUILDTYPE doesnt contain the configuration name, it is simply empty. I am trying to create a simple CMake that retrieves the DLLs of Qt and copy it in the directory in which cmake creates my executable. So in your case, if you have the following directory structure: /CMakeLists.txtĪnd your CMake target to which the command applies is MyTest, then you could add the following to your CMakeLists.txt: add_custom_command(TARGET MyTest POST_BUILD # Adds a post-build event to MyTestĬOMMAND $/bin/) Visual Studio is a multiconfiguration generator. To use cmake from command line, you need to add the cmake binary directory to system path. ctrl + shift + p > cmake: build target will build everything for you. It only works as STATIC at ADDLIBRARY (). If you are using vector-of-bools (now Microsofts) cmake tools then you do not need to use the command line for building. Edit: I was going to mention using a batch file to start Visual Studio (and set the PATH variable in the batch file). Opening app1.sln and building with Visual Studio, it crashes as. Another possibility would be to set the Working Directory under the debugging options to be the directory that has that DLL. For full info run cmake -help-command add_custom_command While I prefer a shared library ( m.dll ), I've made the CMakeLists.txt file: PROJECT ('app1') ADDLIBRARY (m SHARED m.c) ADDEXECUTABLE (myexe main.c) TARGETLINKLIBRARIES (myexe m) The CMake configuration is done and generated done. You can specify the CMAKEINSTALLPREFIX on the commandline of cmake (or in. I'd use add_custom_command to achieve this along with cmake -E copy_if_different. After a succesful build you can copy the executable (see Beginners answer), but perhaps it is nicer to use an install target: Use the install command to specify targets (executables, libraries, headers, etc.) which will be copied to the CMAKEINSTALLPREFIX directory.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |