On Sat, Oct 28, 2017 at 6:10 PM, Carlton Banks <[email protected]> wrote:
> > Den 29. okt. 2017 kl. 02.06 skrev J Decker <[email protected]>: > > I recently added externaproject_add() to download a library, but since it > doesn't do the download until build, I had to put a conditional around the > second part of the cmake that used the libraries it produced so it would do > a cmake configure/generate, cmake build, cmake configure/generate and a > final build and all was good... > > Yes… that sound exactly like the problem I am currently facing.. > > https://github.com/d3x0r/sack.vfs/blob/master/CMakeLists.gui.txt#L61 > > I am not sure I understand how your if statement fixes this?.. when does > it download? > Sorry it's not a very simple project.... the first externalproject is here https://github.com/d3x0r/sack.vfs/blob/master/CMakeLists.gui.txt#L50 the second is immediately after the if that was fore-mentioned. and that first if( exists) linked goes from there until the end of the file.... And it's not just native cmake, it's actually a node module, that uses npm... https://github.com/d3x0r/sack.vfs/blob/master/package.json#L34 build_gui : npm run build-gui-config #cmake-js --CDMAKE_GUI=1 configure && npm run build-gui-run1 #cmake-js build && npm run build-gui-config # cmake-js --CDMAKE_GUI=1 configure && npm run build-gui-run2 #cmake-js build so I can just do 'num run build-gui' and it runs a sequence of steps... Yes, I hate including build scripts in simpler projects... should just be buildable with cmake. Make if you make your library also an externalproject_add() step, with just a SOURCE_DIR specified (or something) then you could probably do it all in one step. > but I coudln't reference any directories that didn't exist yet in > include_directories, or link_directories...until the project had been at > least partially built. > > On Sat, Oct 28, 2017 at 6:00 PM, Craig Scott <[email protected]> > wrote: > > it still doesn’t work… > > I am bit unsure of what is being done here.. I need to include the > libraryportaudio.a to include portaudio into the project. > > which causes an error as the download only occurs during build (make) and > not during cmake. > > Ah, sorry. This particular problem has been fixed >> <https://gitlab.kitware.com/cmake/cmake/merge_requests/1264> on CMake >> master, but it won't be in the 3.10 release (in release candidate stage), >> so that isn't going to help you right now. Possibly you might be able to >> modify the relevant target property directly rather than using >> target_include_directories() - again this is untested, but worth a try: >> >> set_property(TARGET portaudio APPEND PROPERTY >> INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR}/include >> ) >> >> >> If that doesn't work, then I guess modifying your original method to use >> the correct path may be an alternative workaround: >> >> target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${ >> SOURCE_DIR}/include) >> >> >> >> >> >> On Sun, Oct 29, 2017 at 11:47 AM, Carlton Banks <[email protected]> >> wrote: >> >>> >>> Den 29. okt. 2017 kl. 02.29 skrev Craig Scott <[email protected]>: >>> >>> >>> >>> On Sun, Oct 29, 2017 at 11:26 AM, Carlton Banks <[email protected]> >>> wrote: >>> >>>> CMake Error at src/include/record/CMakeLists.txt:28 >>>> (target_include_directories): >>>> Cannot specify include directories for imported target "portaudio". >>>> >>>> >>>> is the problem that externalProject_add only is executed when make is >>>> executed and not when cmake is executed’? >>>> what is `portaudio` here referring to? >>>> >>> >>> The name "portaudio" is the target defined by the add_library() call in >>> my example (the imported target that represents what the >>> ExternalProject_Add() is going to create at build time). >>> >>> ok. >>> >>> Did you also try the INTERFACE IMPORTED alternative? >>> >>> Still the same.. >>> >>> It would be more useful if you showed the full CMakeLists.txt rather >>> than just the error message. >>> >>> >>> The submodule cmakelist: >>> >>> https://pastebin.com/x2WNhK56 >>> >>> tree structure >>> >>> https://pastebin.com/xhPNCkN2 >>> >>> The outer cmakelist includes the inner directories. >>> >>> >>> >>> >>>> Den 29. okt. 2017 kl. 02.19 skrev Craig Scott <[email protected] >>>> >: >>>> >>>> >>>> >>>> On Sun, Oct 29, 2017 at 10:36 AM, Carlton Banks <[email protected]> >>>> wrote: >>>> >>>>> I seem to have some problems executing one of my submodules cmakelist. >>>>> >>>>> MESSAGE(“In record CMAKELIST”) >>>>> >>>>> # Include externalproject {portaudio} if lib/portaudio don't exist. >>>>> MESSAGE(“Download external project”) >>>>> >>>>> INCLUDE(ExternalProject) >>>>> ExternalProject_Add(project_portaudio >>>>> GIT_REPOSITORY https://git.assembla.com/portaudio.git >>>>> PREFIX lib/portaudio >>>>> CONFIGURE_COMMAND <SOURCE_DIR>/configure >>>>> BUILD_IN_SOURCE 1 >>>>> BUILD_COMMAND make >>>>> INSTALL_COMMAND sudo make install >>>>> ) >>>>> ExternalProject_Get_Property(project_portaudio BINARY_DIR) >>>>> ExternalProject_Get_Property(project_portaudio SOURCE_DIR) >>>>> >>>>> SET(portaudio_lib_dir "${BINARY_DIR}/lib/.libs") >>>>> SET(portaudio_inc_dir "${SOURCE_DIR}/include") >>>>> >>>>> add_library(record STATIC record.cpp record.h) >>>>> add_library(libaudio libportaudio.a PATHS ${portaudio_lib_dir}) >>>>> >>>> >>>> What is this second add_library() command intended to do? I'm guessing >>>> you probably instead want to be doing something like this (untested, but >>>> hopefully in the ballpark): >>>> >>>> add_library(portaudio STATIC IMPORTED) >>>> set_target_properties(portaudio PROPERTIES >>>> IMPORTED_LOCATION ${BINARY_DIR}/lib/.libs/libportaudio.a >>>> ) >>>> target_include_directories(portaudio INTERFACE >>>> ${SOURCE_DIR}/include >>>> ) >>>> >>>> add_dependencies(portaudio project_portaudio) # Not sure if this is >>>> allowed for imported targets though >>>> >>>> >>>> I don't recall off the top of my head whether STATIC IMPORTED or >>>> INTERFACE IMPORTED would be the right way to call add_library() in the >>>> above, so try the latter if the former doesn't work for you. >>>> >>>> >>>> >>>>> >>>>> >>>>> # >>>>> # this makes sure we have compiler flags that allow class::class() = >>>>> default (>= C++11) >>>>> target_compile_features(record PUBLIC cxx_defaulted_functions) >>>>> >>>>> >>>>> >>>>> >>>>> target_include_directories(record PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} >>>>> ${project_portaudio}) >>>>> >>>> >>>> You won't need this if you define the portaudio imported library as per >>>> my example above. >>>> >>>> >>>> >>>>> >>>>> >>>>> It cannot find libportaudio.a as externalproject_add() is not being >>>>> executed, the command it executes add_library, which fails as the project >>>>> has not been downloaded… >>>>> >>>>> >>>>> what is wrong here? >>>>> >>>> >>>> The reason for this specific problem is that there's no dependency >>>> relationship between the project_portaudio target defined by the >>>> ExternalProject_Add() call and the record target. Such a relationship is >>>> only created through a suitable call to target_link_libraries() or >>>> add_dependencies(), or through arguments like DEPENDS for commands that >>>> offer such features (e.g. add_custom_target() and add_custom_command()). >>>> >>>> >>>> -- >>>> Craig Scott >>>> Melbourne, Australia >>>> https://crascit.com >>>> >>>> >>>> >>> >>> >>> -- >>> Craig Scott >>> Melbourne, Australia >>> https://crascit.com >>> >>> >>> >> >> >> -- >> Craig Scott >> Melbourne, Australia >> https://crascit.com >> >> -- >> >> Powered by www.kitware.com >> >> Please keep messages on-topic and check the CMake FAQ at: >> http://www.cmake.org/Wiki/CMake_FAQ >> >> Kitware offers various services to support the CMake community. For more >> information on each offering, please visit: >> >> CMake Support: http://cmake.org/cmake/help/support.html >> CMake Consulting: http://cmake.org/cmake/help/consulting.html >> CMake Training Courses: http://cmake.org/cmake/help/training.html >> >> Visit other Kitware open-source projects at >> http://www.kitware.com/opensource/opensource.html >> >> Follow this link to subscribe/unsubscribe: >> http://public.kitware.com/mailman/listinfo/cmake >> > > >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
