Re: [CMake] no convenience target for generated files?
Does cd bar make help Tell you anything? On Wednesday, April 8, 2015, Dave Yost wrote: > I’m using add_custom_command to generate a file, “bar.cc”. > > It would be convenient if I could say > make bar.cc > or > make bar/bar.cc > but neither of these work, and I can’t see a target in the Makefiles that > I can use. > > There is a way to make bar.cc.o, but not bar.cc > > 0 Wed 14:15:54 yost DaveBook ~/p/c++/cmake/target-for-generate > 241 Z% bundle `findf *` > [ find CMakeLists.txt bar foo.cc -type f ] > #!/usr/bin/env unbundle > # See http://yost.com/computers/bundle/ > CMakeLists.txt > cmake_minimum_required(VERSION 3.2.1) > > project(yost-cmake-example) > > add_subdirectory(bar) > > add_executable (foo foo.cc) > target_link_libraries(foo bar) > > bar/bar.hh > extern char* str1; > > bar/CMakeLists.txt > > add_executable(genBar genBar.cc) > > add_custom_command( > OUTPUT bar.cc > COMMAND genBar > bar.cc > DEPENDS genBar) > > add_library (bar SHARED bar.cc) > target_include_directories(bar PUBLIC .) > > bar/genBar.cc > #include > > int main(int argc, char** argv) { > std::cout > << "#include \"bar.hh\"\n\n" >"char str1array[] = \"Hello!\";\n" >"char* str1 = str1array;\n"; > return 0; > } > > foo.cc > #include > #include > > int main(int argc, char** argv) { > std::cout << str1 << std::endl; > return 0; > } > > > 0 Wed 14:15:57 yost DaveBook ~/p/c++/cmake/target-for-generate > 242 Z% mkdir build > 0 Wed 14:16:02 yost DaveBook ~/p/c++/cmake/target-for-generate > 243 Z% cd build > 0 Wed 14:16:03 yost DaveBook ~/p/c++/cmake/target-for-generate/build > 244 Z% cmake .. > -- The C compiler identification is AppleClang 6.0.0.657 > -- The CXX compiler identification is AppleClang 6.0.0.657 > -- Check for working C compiler: > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc > -- Check for working C compiler: > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc > -- works > -- Detecting C compiler ABI info > -- Detecting C compiler ABI info - done > -- Detecting C compile features > -- Detecting C compile features - done > -- Check for working CXX compiler: > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ > -- Check for working CXX compiler: > /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ > -- works > -- Detecting CXX compiler ABI info > -- Detecting CXX compiler ABI info - done > -- Detecting CXX compile features > -- Detecting CXX compile features - done > -- Configuring done > -- Generating done > -- Build files have been written to: > /Users/yost/p/c++/cmake/target-for-generate/build > 0 Wed 14:16:07 yost DaveBook ~/p/c++/cmake/target-for-generate/build > 245 Z% make > Scanning dependencies of target genBar > [ 14%] Building CXX object bar/CMakeFiles/genBar.dir/genBar.cc.o > [ 28%] Linking CXX executable genBar > [ 28%] Built target genBar > [ 42%] Generating bar.cc > Scanning dependencies of target bar > [ 57%] Building CXX object bar/CMakeFiles/bar.dir/bar.cc.o > [ 71%] Linking CXX shared library libbar.dylib > [ 71%] Built target bar > Scanning dependencies of target foo > [ 85%] Building CXX object CMakeFiles/foo.dir/foo.cc.o > [100%] Linking CXX executable foo > [100%] Built target foo > 0 Wed 14:16:09 yost DaveBook ~/p/c++/cmake/target-for-generate/build > 246 Z% rm bar/bar.cc > 0 Wed 14:16:15 yost DaveBook ~/p/c++/cmake/target-for-generate/build > 247 Z% make bar/bar.cc > make: *** No rule to make target `bar/bar.cc'. Stop. > 2 Wed 14:16:24 yost DaveBook ~/p/c++/cmake/target-for-generate/build > 248 Z% make bar.cc > make: *** No rule to make target `bar.cc'. Stop. > 2 Wed 14:16:27 yost DaveBook ~/p/c++/cmake/target-for-generate/build > 249 Z% cd bar > 0 Wed 14:19:20 yost DaveBook ~/p/c++/cmake/target-for-generate/build/bar > 253 Z% make bar.cc > make: *** No rule to make target `bar.cc'. Stop. > 2 Wed 14:19:22 yost DaveBook ~/p/c++/cmake/target-for-generate/build/bar > 254 Z% make bar.cc.o > Generating bar.cc > Building CXX object bar/CMakeFiles/bar.dir/bar.cc.o > 0 Wed 14:19:25 yost DaveBook ~/p/c++/cmake/target-for-generate/build/bar > 255 Z% > > > -- 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
Re: [CMake] FindOpenMP not working on VS2010 Pro
Sorry for the noise. My Cache had variables leftover from VS 2010 Express. Thanks, Rob On Wed, Apr 8, 2015 at 3:44 PM, Rob McDonald wrote: > For some reason, FindOpenMP succeeds -- but reports failure for me on > Visual Studio 2010 Pro. This is with the latest CMake just in case... > > 1> -- Try OpenMP C flag = [/openmp] > 1> -- Performing Test OpenMP_FLAG_DETECTED > 1> -- Performing Test OpenMP_FLAG_DETECTED - Success > 1> -- Try OpenMP CXX flag = [/openmp] > 1> -- Performing Test OpenMP_FLAG_DETECTED > 1> -- Performing Test OpenMP_FLAG_DETECTED - Success > 1> -- Could NOT find OpenMP (missing: OpenMP_C_FLAGS OpenMP_CXX_FLAGS) > > > Any suggestions? -- 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
[CMake] FindOpenMP not working on VS2010 Pro
For some reason, FindOpenMP succeeds -- but reports failure for me on Visual Studio 2010 Pro. This is with the latest CMake just in case... 1> -- Try OpenMP C flag = [/openmp] 1> -- Performing Test OpenMP_FLAG_DETECTED 1> -- Performing Test OpenMP_FLAG_DETECTED - Success 1> -- Try OpenMP CXX flag = [/openmp] 1> -- Performing Test OpenMP_FLAG_DETECTED 1> -- Performing Test OpenMP_FLAG_DETECTED - Success 1> -- Could NOT find OpenMP (missing: OpenMP_C_FLAGS OpenMP_CXX_FLAGS) Any suggestions? -- 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
[CMake] no convenience target for generated files?
I’m using add_custom_command to generate a file, “bar.cc”. It would be convenient if I could say make bar.cc or make bar/bar.cc but neither of these work, and I can’t see a target in the Makefiles that I can use. There is a way to make bar.cc.o, but not bar.cc 0 Wed 14:15:54 yost DaveBook ~/p/c++/cmake/target-for-generate 241 Z% bundle `findf *` [ find CMakeLists.txt bar foo.cc -type f ] #!/usr/bin/env unbundle # See http://yost.com/computers/bundle/ CMakeLists.txt cmake_minimum_required(VERSION 3.2.1) project(yost-cmake-example) add_subdirectory(bar) add_executable (foo foo.cc) target_link_libraries(foo bar) bar/bar.hh extern char* str1; bar/CMakeLists.txt add_executable(genBar genBar.cc) add_custom_command( OUTPUT bar.cc COMMAND genBar > bar.cc DEPENDS genBar) add_library (bar SHARED bar.cc) target_include_directories(bar PUBLIC .) bar/genBar.cc #include int main(int argc, char** argv) { std::cout << "#include \"bar.hh\"\n\n" "char str1array[] = \"Hello!\";\n" "char* str1 = str1array;\n"; return 0; } foo.cc #include #include int main(int argc, char** argv) { std::cout << str1 << std::endl; return 0; } 0 Wed 14:15:57 yost DaveBook ~/p/c++/cmake/target-for-generate 242 Z% mkdir build 0 Wed 14:16:02 yost DaveBook ~/p/c++/cmake/target-for-generate 243 Z% cd build 0 Wed 14:16:03 yost DaveBook ~/p/c++/cmake/target-for-generate/build 244 Z% cmake .. -- The C compiler identification is AppleClang 6.0.0.657 -- The CXX compiler identification is AppleClang 6.0.0.657 -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Configuring done -- Generating done -- Build files have been written to: /Users/yost/p/c++/cmake/target-for-generate/build 0 Wed 14:16:07 yost DaveBook ~/p/c++/cmake/target-for-generate/build 245 Z% make Scanning dependencies of target genBar [ 14%] Building CXX object bar/CMakeFiles/genBar.dir/genBar.cc.o [ 28%] Linking CXX executable genBar [ 28%] Built target genBar [ 42%] Generating bar.cc Scanning dependencies of target bar [ 57%] Building CXX object bar/CMakeFiles/bar.dir/bar.cc.o [ 71%] Linking CXX shared library libbar.dylib [ 71%] Built target bar Scanning dependencies of target foo [ 85%] Building CXX object CMakeFiles/foo.dir/foo.cc.o [100%] Linking CXX executable foo [100%] Built target foo 0 Wed 14:16:09 yost DaveBook ~/p/c++/cmake/target-for-generate/build 246 Z% rm bar/bar.cc 0 Wed 14:16:15 yost DaveBook ~/p/c++/cmake/target-for-generate/build 247 Z% make bar/bar.cc make: *** No rule to make target `bar/bar.cc'. Stop. 2 Wed 14:16:24 yost DaveBook ~/p/c++/cmake/target-for-generate/build 248 Z% make bar.cc make: *** No rule to make target `bar.cc'. Stop. 2 Wed 14:16:27 yost DaveBook ~/p/c++/cmake/target-for-generate/build 249 Z% cd bar 0 Wed 14:19:20 yost DaveBook ~/p/c++/cmake/target-for-generate/build/bar 253 Z% make bar.cc make: *** No rule to make target `bar.cc'. Stop. 2 Wed 14:19:22 yost DaveBook ~/p/c++/cmake/target-for-generate/build/bar 254 Z% make bar.cc.o Generating bar.cc Building CXX object bar/CMakeFiles/bar.dir/bar.cc.o 0 Wed 14:19:25 yost DaveBook ~/p/c++/cmake/target-for-generate/build/bar 255 Z% -- 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
Re: [CMake] Running custom executable
The issue with the add_custom_command() and DEPENDS is that the custom commands will be in CMakeLists.txt files throughout the solution, and it appears to indicate that that form only works with a target created in the same directory. On Wed, Apr 8, 2015 at 1:12 PM, Alexander Neundorf wrote: > On Tuesday, April 07, 2015 15:24:18 Daniel Dilts wrote: > > Looking at the way these things work, it seems to me that the ideal > > solution to my situation, if it is possible, is to do a > > add_custom_command() for each source file, and then do a > > add_custom_target() that has all of the custom commands as PRE_BUILD > events. > > No, PRE_BUILD works only for Visual Studio generators according to the > docs. > > I think you need to give the list of output files generated using > add_custom_command() as DEPENDS to add_custom_target(). > > Alex > > -- 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
[CMake] Default INTERFACE_POSITION_INDEPENDENT_CODE value for static library
Hi, I've got next error while trying to link static library to shared one on Linux: /usr/bin/ld: ...: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC This error can be detected on CMake configure step instead of linker stage if I add next code: set_property(TARGET ... PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE YES) in this case error message is: CMake Error: Property POSITION_INDEPENDENT_CODE on target "..." does not match the INTERFACE_POSITION_INDEPENDENT_CODE property requirement of dependency "...". because there is POSITION_INDEPENDENT_CODE=YES default value for shared library. So I wonder why there is no default value INTERFACE_POSITION_INDEPENDENT_CODE=NO for static one? Thanks, Ruslo -- 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
Re: [CMake] Running custom executable
On Tuesday, April 07, 2015 15:24:18 Daniel Dilts wrote: > Looking at the way these things work, it seems to me that the ideal > solution to my situation, if it is possible, is to do a > add_custom_command() for each source file, and then do a > add_custom_target() that has all of the custom commands as PRE_BUILD events. No, PRE_BUILD works only for Visual Studio generators according to the docs. I think you need to give the list of output files generated using add_custom_command() as DEPENDS to add_custom_target(). Alex -- 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
Re: [CMake] generator expressions
Hi Micha, When using generator expressions inside target_include_directories you must qualify all paths. Either by using absolute paths, or using one of the helper variables that allows CMake to determine where the relative path should be evaluated from. This is all really well documented at: http://www.cmake.org/cmake/help/v3.2/manual/cmake-buildsystem.7.html#include-directories-and-usage-requirements On Wed, Apr 8, 2015 at 3:26 AM, Micha Renner wrote: > Hi, > > I try to understand the concept of generator expressions with little > avail. > > For the current project I thought, I could use them in combination with > TARGET_INCLUDE_DIRECTORIES. > Instead of writting > IF(t1) > TARGET_INCLUDE_DIRECTORIES(cTest PRIVATE path/to/h1 PRIVATE > path/to/h2) > ELSE(t1) > TARGET_INCLUDE_DIRECTORIES(cTest PRIVATE path/to/h1) > ENDIF(t1) > > it should be more elegant > > SET(t1 ON) > ADD_EXECUTABLE(cTest CTest.c cTest.h) > TARGET_INCLUDE_DIRECTORIES(cTest PRIVATE path/to/h1 $< > $:"PRIVATE path/to/h2") > > Of course this creates a major disaster. > > -- > CMake Warning (dev) in CMakeLists.txt: > Policy CMP0021 is not set: Fatal error on relative paths in > INCLUDE_DIRECTORIES target property. Run "cmake --help-policy > CMP0021" for > policy details. Use the cmake_policy command to set the policy and > suppress this warning. > > Found relative path while evaluating include directories of "cTest": > > ""PRIVATE path/to/h2"" > > This warning is for project developers. Use -Wno-dev to suppress it. > > cmake: > /home/gildemeister/Picture/work-c/CMakeSrc/cmake-3.2.1/Source/cmLocalGenerator.cxx:2923: > std::string cmLocalGenerator::ConvertToRelativePath(const > std::vector >&, const string&, bool): Assertion > `in_remote[0] != '\"'' failed. > Abgebrochen (Speicherabzug geschrieben) > -- > > Is there a way to solve this with a generator expression? > > Michael > > > > -- > > 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
[CMake] generator expressions
Hi, I try to understand the concept of generator expressions with little avail. For the current project I thought, I could use them in combination with TARGET_INCLUDE_DIRECTORIES. Instead of writting IF(t1) TARGET_INCLUDE_DIRECTORIES(cTest PRIVATE path/to/h1 PRIVATE path/to/h2) ELSE(t1) TARGET_INCLUDE_DIRECTORIES(cTest PRIVATE path/to/h1) ENDIF(t1) it should be more elegant SET(t1 ON) ADD_EXECUTABLE(cTest CTest.c cTest.h) TARGET_INCLUDE_DIRECTORIES(cTest PRIVATE path/to/h1 $< $:"PRIVATE path/to/h2") Of course this creates a major disaster. -- CMake Warning (dev) in CMakeLists.txt: Policy CMP0021 is not set: Fatal error on relative paths in INCLUDE_DIRECTORIES target property. Run "cmake --help-policy CMP0021" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Found relative path while evaluating include directories of "cTest": ""PRIVATE path/to/h2"" This warning is for project developers. Use -Wno-dev to suppress it. cmake: /home/gildemeister/Picture/work-c/CMakeSrc/cmake-3.2.1/Source/cmLocalGenerator.cxx:2923: std::string cmLocalGenerator::ConvertToRelativePath(const std::vector >&, const string&, bool): Assertion `in_remote[0] != '\"'' failed. Abgebrochen (Speicherabzug geschrieben) -- Is there a way to solve this with a generator expression? Michael -- 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