Re: [CMake] error executing script with cmake -P
On Thu, Oct 17, 2019 at 2:14 AM Edoardo Pasca wrote: > Hi Tom, > > I thought ${testdata} was going to be filled in by the actual > patch_script.cmake at this line. > > file (STRINGS TestData.py testdata NEWLINE_CONSUME) > Sorry, some nasty formatting in my email client had me misreading your script. My advice is mainly based on this error: CMake Error at build/patch_script.cmake:3 (string): string sub-command REPLACE requires at least four arguments Looking at this line: string(REPLACE \"sys.prefix\" \"os.environ[\\\'SIRF_INSTALL_PATH\\\']\" patched \${testdata}) The most likely possible reason for that error being reported by CMake is that ${testdata} is not defined when that line of script is executed. What does line 3 of patch_script.cmake look like immediately after the error message is output? My guess is that it looks something like this: string(REPLACE "sys.prefix" "os.environ[\'SIRF_INSTALL_PATH\']" patched ) As you'll notice REPLACE is only receiving 3 args in the above version. Also note: I don't think you need to escape the single quotes in the os.environ argument (unless they must be escaped in the final output). Basic toy scripts here show it as unnecessary unless they must be escaped in the patched file. > > So it appears that this command doesn't quite work. > > I'll try also Alan's suggestion. > > Thanks > > Edo > > On Tue, Oct 15, 2019 at 7:00 PM Tom Finegan wrote: > >> It looks like you aren't passing the $testdata variable down to the >> script. From your message it looks like you need to add the following to >> your PATCH_COMMAND: >> >> -Dtestdata=${testdata} >> >> You must explicitly pass $testdata (and any other variables defined in >> the calling script) to patch_script.cmake via -D parameters on the command >> line. Also note that the -Dvar=value args must precede the -P
Re: [CMake] error executing script with cmake -P
It looks like you aren't passing the $testdata variable down to the script. >From your message it looks like you need to add the following to your PATCH_COMMAND: -Dtestdata=${testdata} You must explicitly pass $testdata (and any other variables defined in the calling script) to patch_script.cmake via -D parameters on the command line. Also note that the -Dvar=value args must precede the -P
Re: [CMake] Trouble with CMAKE_EXE_LINKER_FLAGS not honored
On Wed, Jun 5, 2019 at 9:29 AM Bryan Christ wrote: > Tom, > > I'll give that a try. Can that variable be changed after project() is > called? > Yes, you should be able to change it at any point in your CMake script(s). Remember that CMAKE__LINKER_FLAGS will effect all targets. Restricting your settings changes to the targets for which they are intended is usually better than touching variables like CMAKE_SHARED_LINKER_FLAGS. You may have better results using target_link_libraries() to set your flags. > > On Tue, Jun 4, 2019 at 5:24 PM Tom Finegan wrote: > >> I think you want CMAKE_SHARED_LINKER_FLAGS: >> >> >> https://cmake.org/cmake/help/latest/variable/CMAKE_SHARED_LINKER_FLAGS.html >> >> You can also use target_link_libraries to pass linker flags: >> >> https://cmake.org/cmake/help/latest/command/target_link_libraries.html >> >> On Tue, Jun 4, 2019 at 1:12 PM Bryan Christ >> wrote: >> >>> For building my project on Linux with gcc I set the following. >>> >>> set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} >>> -Wl,--no-as-needed") >>> >>> Later, if, the system appears to be OSX, I change it: >>> >>> if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") >>> >>> set(CMAKE_EXE_LINKER_FLAGS "-Wl,-undefined -Wl,dynamic_lookup") >>> set(CMAKE_PREFIX_PATH /usr/local/opt/ncurses) >>> >>> endif() >>> >>> However, when creating the shared object, linking fails. The flags are >>> not being passed to clang as expected. When I dive into >>> CMakeFile/vterm-shared.dir/link.txt I confirm that the wrong flags are >>> there. >>> >>> What am I doing wrong? >>> >>> -- >>> Bryan >>> <>< >>> -- >>> >>> 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: >>> https://cmake.org/mailman/listinfo/cmake >>> >> > > -- > Bryan > <>< > -- 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: https://cmake.org/mailman/listinfo/cmake
Re: [CMake] Trouble with CMAKE_EXE_LINKER_FLAGS not honored
I think you want CMAKE_SHARED_LINKER_FLAGS: https://cmake.org/cmake/help/latest/variable/CMAKE_SHARED_LINKER_FLAGS.html You can also use target_link_libraries to pass linker flags: https://cmake.org/cmake/help/latest/command/target_link_libraries.html On Tue, Jun 4, 2019 at 1:12 PM Bryan Christ wrote: > For building my project on Linux with gcc I set the following. > > set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed") > > Later, if, the system appears to be OSX, I change it: > > if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") > > set(CMAKE_EXE_LINKER_FLAGS "-Wl,-undefined -Wl,dynamic_lookup") > set(CMAKE_PREFIX_PATH /usr/local/opt/ncurses) > > endif() > > However, when creating the shared object, linking fails. The flags are > not being passed to clang as expected. When I dive into > CMakeFile/vterm-shared.dir/link.txt I confirm that the wrong flags are > there. > > What am I doing wrong? > > -- > Bryan > <>< > -- > > 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: > https://cmake.org/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: https://cmake.org/mailman/listinfo/cmake
Re: [CMake] The Xcode generator and ASM_NASM support
On Wed, Oct 3, 2018 at 10:29 AM Gregor Jasny wrote: > Hello, > > > On 10/3/18 6:08 PM, Tom Finegan via CMake wrote: > > I'm trying to get rid of some local CMake scripting for building assembly > > with nasm and yasm, but I'm running into a problem with the Xcode > generator. > > > > For the make and ninja generators, everything is fine-- nasm and yasm are > > both working as expected. > > > This works fine with Visual Studio as well. > > The same is not true for Xcode. When building a target that includes > > assembly files Xcode outputs the warnings like the following during its > > "Check dependencies" step: > > > > warning: no rule to process file of type sourcecode for > > architecture x86_64 > > If the Xcode included nasm and the default Xcode flags are good enough > for you you might get away with: > > set_source_files_properties(${yasm_file} PROPERTIES >XCODE_EXPLICIT_FILE_TYPE "sourcecode.nasm") > > This has no impact on Xcode's behavior at build time; I see the same warning each time Xcode encounters a .asm file. I can see that the property is actually set on the .asm files, so it is at least doing something. Just not quite enough. :) > Otherwise I had to create a add_custom_command for every file and > pointed to a shell script that based on all architectures found in ARCHS > ran yasm and in the end called lipo to create the final fat .o file. > Indeed. I use add_custom_command() and then add the objects into a dependent target. I was hoping to drop the script that was doing the work. Oh well. Just in case, here's the util macro I'm using to do the work-- maybe someone can spot something silly I've missed: macro(add_asm_object_library target dependent_target sources) if("${${sources}}" STREQUAL "") message(FATAL_ERROR "--- add_asm_object_library: empty source list.") endif() add_library(${target} OBJECT ${${sources}}) target_sources(${dependent_target} PRIVATE $) if("${CMAKE_ASM_NASM_COMPILER}" MATCHES "nasm") # Include path handling in nasm is broken. If the trailing slash is omitted # nasm cannot find includes. Explicitly add the necessary include paths with # trailing slashes. target_compile_options(${target} PRIVATE "-I${AOM_ROOT}/" "-I${AOM_CONFIG_DIR}/") endif() if(XCODE) set_source_files_properties(${${sources}} PROPERTIES XCODE_EXPLICIT_FILE_TYPE "sourcecode.nasm") endif() list(APPEND AOM_LIB_TARGETS ${target}) endmacro() > > Hope that helps, > -Gregor > -- 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: https://cmake.org/mailman/listinfo/cmake
[CMake] The Xcode generator and ASM_NASM support
I'm trying to get rid of some local CMake scripting for building assembly with nasm and yasm, but I'm running into a problem with the Xcode generator. For the make and ninja generators, everything is fine-- nasm and yasm are both working as expected. The same is not true for Xcode. When building a target that includes assembly files Xcode outputs the warnings like the following during its "Check dependencies" step: warning: no rule to process file of type sourcecode for architecture x86_64 This is with CMake v3.12.1, but I'm pretty sure this has nothing to do with CMake version. Is there an extra step necessary to get this working with the Xcode generator? I would like to get rid of the extra cmake scripting that handles assembly in the project I'm working on. I have tried the following: 1) Building an object library with the assembly sources. 2) Building a static library with the assembly sources. 3) Adding the assembly sources to an existing library target. All attempts produce an Xcode project that outputs the warning noted above, and then fails to build because of link errors or missing object files (depending on the method used). Thanks for any advice, Tom -- 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: https://cmake.org/mailman/listinfo/cmake