Re: [CMake] Proper options with cmake
Gennadiy Rozental wrote: > Hi, > > How do I implement a proper option with default value. Both boolean and > string. > > If I define option like this: > > option( GOO "descr" OFF ) > > here is what happends: > > 1. First time I run cmake without specifying GOO, GOO is OFF > 2. Any time I run cmake with -DGOO=ON, GOO is ON > 3. Any time I run cmake with -DGOO=OFF, GOO is OFF > 4. Any time after the first I run cmake without specifying GOO, GOO is the > same as it was in previous run, not necessarily OFF. > > My problem is semantic of (4). What I want is for GOO to have default value > I specified if one was not provided, regardless of what was the value of GOO > in previous run. This seems like such an obvious expectation, that I do not > understand why it is not the case now. That is the sense of option(): provide a persistent choice. What you want sounds like: if(NOT DEFINED GOO) set(GOO Off) endif() Eike -- signature.asc Description: This is a digitally signed message part. -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] how to write the following comand into cmake file.
thanks. but how to use it. how to install it into cmake. 在 2013-06-25 00:16:01,"Jed Brown" 写道: >丁老师 writes: > >> I develop a parallel code with PETSc, it can sucessfully compiled with >> the following mpic++ command, but how to translate it into a cmake >> file. so i can further develop it in kdevelop 4.4. > >See FindPETSc.cmake at https://github.com/jedbrown/cmake-modules -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] how to write the following comand into cmake file.
丁老师 writes: > thanks. but how to use it. how to install it into cmake. Like all Find*.cmake modules. It follows the usual conventions. > 在 2013-06-25 00:16:01,"Jed Brown" 写道: >>丁老师 writes: >> >>> I develop a parallel code with PETSc, it can sucessfully compiled with >>> the following mpic++ command, but how to translate it into a cmake >>> file. so i can further develop it in kdevelop 4.4. >> >>See FindPETSc.cmake at https://github.com/jedbrown/cmake-modules pgpRK89D3zrdr.pgp Description: PGP signature -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] how to write the following comand into cmake file.
OK, gotcha, After trying out a recent build of Kdevelop4, I decided to give CMake a go. I currently have a project running utilizing MPI (parallellization libraries). This is nice and not that hard to use, but the linking of the project gets arbitrarily complicated. What helped me before when using Kdevelop3 and automake was this solution. This year around the solution is so simple, I figured I’d share with the world how to write a Hello World program utilizing OpenMPI and CMake. I will not cover the installation of those tools, that you have to find out yourself since it depends on what OS you use. I have to say that Kdevelop4 looks stunning. It has a lot of tools, automatically checks headers included in the project for functions etc, has semantic code control, wonderful integration with CMake, and generally looks like pure heaven for a programmer. At the moment it does crash every now and then, but then again it is not a finished product. I’m sure I could write ten pages about how good it is, but that is for another post when I have tested it a bit more thoroughly.. Now, first the C++ code, which initializes the MPI, and then prints Hello World from each parallell process + the time it has used to get there since it was initialized. I have named the file "main.cpp" #include #include static int numprocs; int main(int argc, char **argv) { int my_rank; // MPI initializations MPI_Status status; MPI_Init (&argc, &argv); MPI_Comm_size (MPI_COMM_WORLD, &numprocs); MPI_Comm_rank (MPI_COMM_WORLD, &my_rank); double time_start = MPI_Wtime(); std::cout << "Hello World, my rank is " << my_rank <<" "<< MPI_Wtime() - time_start << std::endl; // End MPI MPI_Finalize (); return 0; } Now if you find this complicated then have a look at some tutorial for MPI. You can basically consider the four lines of MPI initializations a black hole, then you have a timer which starts, and the Hello World message. At the end of the code it is important to finalize MPI, otherwise you get an error message. Anyway, this is not the important part, because it is CMake that makes my life THAT much easier. Have a look at the CMake file: PROJECT(test) ADD_EXECUTABLE(test main.cpp) SET(CMAKE_C_COMPILER mpicc) SET(CMAKE_CXX_COMPILER mpicxx) target_link_libraries(test mpi) That’s it! The first line defines the name of the project. Next, we define the name of the executable to be "test", and the files that executable depends on, "main.cpp". After that we define the C compilers because MPI code should be compiled with these special compilers which are basically the gcc with something extra (I consider them black holes). Finally, we need to link the project called "test" to the library called "MPI", which is done in the last line. Simple as that! Afterwards you create another folder, e.g. "build", inside your project. Then you generate the makefile with "cmake ../" (where ../ denotes the location of your project), and compile/link with "make". The code can be ran with the command "mpirun -np 2 ./test", where 2 is the number of processes. Et voila! Update 24. of May: So I have noticed that quite a few people have clicked on this post. I figured I wanted to mention (after learning quite a bit more CMake), that in principle I did not use much of the features of CMake in this example. Hence I wanted to add an alternative CMake script that better exemplifies the power of CMake. Consider the following code for CMakeLists.txt: cmake_minimum_required(VERSION 2.8) project(mytest) add_executable(mytest main.cpp) # Require MPI for this project: find_package(MPI REQUIRED) set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS}) set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS}) include_directories(MPI_INCLUDE_PATH) target_link_libraries(mytest ${MPI_LIBRARIES}) # Add a test: enable_testing() add_test(SimpleTest ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 4 ${CMAKE_CURRENT_BINARY_DIR}/mytest) Instead of relying on using the compiler wrappers (which depends on you knowing the precise name of these binaries), we here use the functionality find_package() in CMake. This calls an external function which will set up the environment variables you need to link to MPI. We add the word “REQUIRED” so that CMake knows that MPI is … required. The script might look more complex, but it is much more powerful. The way we set it up here we actually do it in a way that should work independent of which MPI installation one has. I also added a test demo at the bottom that runs the binary with four parallell processes. The test can be ran after “make” using the command “ctest”. From:http://eothred.wordpress.com/2010/02/25/hello-world-cmakeopenmpi/ 2013/6/24 丁老师 : > I develop a parallel code with PETSc, it can sucessfully compiled with the > following mpic++ command, but how to translate it into a cmake file. so i > can further develop it in kdevelop 4.4. > > mpic++ main.cpp -o main -I/home/ztdep/Downloads/petsc-3.3-p6/inc… > -I/home/
Re: [CMake] how to write the following comand into cmake file.
I don't know what do you want to do? It's seems mpic++ didn't support by mpic++. 2013/6/24 丁老师 : > I develop a parallel code with PETSc, it can sucessfully compiled with the > following mpic++ command, but how to translate it into a cmake file. so i > can further develop it in kdevelop 4.4. > > mpic++ main.cpp -o main -I/home/ztdep/Downloads/petsc-3.3-p6/inc… > -I/home/ztdep/Downloads/petsc-3.3-p6/arc… > -Wl,-rpath,/home/ztdep/Downloads/petsc-3… > -L/home/ztdep/Downloads/petsc-3.3-p6/arc… -lpetsc -lX11 > -Wl,-rpath,/home/ztdep/Downloads/petsc-3… -lHYPRE -lcmumps -ldmumps -lsmumps > -lzmumps -lmumps_common -lpord -lsuperlu_dist_3.1 -lparmetis -lmetis > -lscalapack -lblacs -lpthread -llcg -lflapack -lfblas -lm > -L/usr/lib64/gcc/x86_64-suse-linux/4.7 -L/usr/x86_64-suse-linux/lib > -lmpichf90 -lgfortran -lm -lgfortran -lm -lquadmath -lm -lmpichcxx -lstdc++ > -ldl -lmpich -lopa -lmpl -lrt -lpthread -lgcc_s -ldl > > > > > > -- > > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake -- 此致 礼 罗勇刚 Yours sincerely, Yonggang Luo -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] CMAKE_BUILD_TYPE case sensitivity
Is the CMAKE_BUILD_TYPE case sensitive. I have seen references to both "Debug" and "DEBUG" in the mailing lists. Thanks, -Anil -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Something amiss from RPATH
On Mon, Jun 17, 2013 at 8:59 PM, Alexander Neundorf wrote: > On Tuesday 11 June 2013, Vittorio Giovara wrote: > > Hi, > > I've been following the guide > > http://www.cmake.org/Wiki/CMake_RPATH_handlingfor using my libraries > > with my executable on Unix, but even with any > > combination of them doesn't change the final result: > > > > anexe: error while loading shared libraries: libaname.so.1: cannot open > > shared object file: No such file or directory > > > > This is running it both installed and in the build tree, even objdump -x > > anexe|grep RPATH doesn't report anything. The only way I found to make > this > > work is to manually set LINK_FLAGS for each target and set -Wl,-rpath,... > > > > What is going on? Why do all variables seem to be ignored? > > I'm using cmake 2.8.10 on ubuntu 12.04 32 bit. > > Vittorio > > can you post a minimal example project which shows the problem ? > > Thanks > Alex > > As I mentioned in a previous post, I found out that there was a set(CMAKE_SKIP_BUILD_RPATH true) set in another CMakeLists from a project I embedded in mine. Apparently cache got confused and/or that second set took precedence and disabled my rpath settings. Best, Vittorio -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] INSTALL_NAME_DIR ignored in add_library?
On Thu, Jun 13, 2013 at 4:54 PM, Clinton Stimpson wrote: > The INSTALL_NAME_DIR property applies at install time. If you want it to > apply at build time, where it would show up on the link line, you need to > set > BUILD_WITH_INSTALL_RPATH. > > I found the issues, CMAKE_INSTALL_NAME_DIR got ignored because I had another project CMakeLists.txt embedded in mine which set CMAKE_SKIP_BUILD_RPATH to false, thus preventing any modifcation of the rpath/dylib path. > And since you referenced previous mailing list rpath/Mac discussions, you > may > want to look at this blog, which includes the recommendation to not set > INSTALL_NAME_DIR anymore (available in the upcoming CMake 2.8.12 or > available > now on if you compile the current master). > http://www.kitware.com/blog/home/post/510 > > Thanks, good to know. Cheers, Vittorio -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] Strange escaping of cache variables
Hi, I'm trying to make a module to find out how to "stringify" a symbol in Fortran preprocessing. With most compiler you would write #SYMBOL as in C, but with gfortran, you have to use 'SYMBOL' (but it between single quotes) I've written a module that uses try_run (bad for cross compiling but I didn't find any other solution) that writes the correct solution to cache with set(FPP_STRINGIFY_SYMBOL "${FOUND_SYMBOL}" CACHE STRING "Stringyfication symbol for the Fortran Preprocessor") The problem is that some sort of escaping seems to be applied ... When${FOUND_SYMBOL} contains 'SYMBOL' what's written to cache is SYMBOL (without the quotes) I've worked around the problem by adding spaces (writing " ${FOUND_SYMBOL} " instead) But I'd like to understand what kind of escaping is applied and that would be great if it was actually documented. Regards, Julien -- Julien Bigot, Ph.D. -- http://work.julien-bigot.fr Maison de la Simulation USR 3441 - bât. 565 - CEA Saclay 91191 Gif-sur-Yvette CEDEX - FRANCE phone: (+33) 1 69 08 01 75 -- xmpp: jbi...@jabber.org signature.asc Description: This is a digitally signed message part. -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] how to write the following comand into cmake file.
I develop a parallel code with PETSc, it can sucessfully compiled with the following mpic++ command, but how to translate it into a cmake file. so i can further develop it in kdevelop 4.4. mpic++ main.cpp -o main -I/home/ztdep/Downloads/petsc-3.3-p6/inc… -I/home/ztdep/Downloads/petsc-3.3-p6/arc… -Wl,-rpath,/home/ztdep/Downloads/petsc-3… -L/home/ztdep/Downloads/petsc-3.3-p6/arc… -lpetsc -lX11 -Wl,-rpath,/home/ztdep/Downloads/petsc-3… -lHYPRE -lcmumps -ldmumps -lsmumps -lzmumps -lmumps_common -lpord -lsuperlu_dist_3.1 -lparmetis -lmetis -lscalapack -lblacs -lpthread -llcg -lflapack -lfblas -lm -L/usr/lib64/gcc/x86_64-suse-linux/4.7 -L/usr/x86_64-suse-linux/lib -lmpichf90 -lgfortran -lm -lgfortran -lm -lquadmath -lm -lmpichcxx -lstdc++ -ldl -lmpich -lopa -lmpl -lrt -lpthread -lgcc_s -ldl -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMAKE set linker variables (including custom linker script)
On Thu, Jun 20, 2013 at 9:57 PM, Martin Osterloh < martin.oster...@dartmouth.edu> wrote: > I am currently migrating my project to CMAKE and so far it has been > going quite well. I am using the standard “ld” as a linker with options –N > –S –q –T > > ** ** > > In my CMakeLists.txt I do: > > Set(CMAKE_C_LINK_EXECUTABLE “ld –N –S –q –T ”)*** > * > > ** ** > > This seems to invoke the correct linker script. However, it also fails to > produce any binaries! No compilation or linker errors (even with --verbose). > > > The code compiles fine and produces executables without setting this > variable. > > ** > Shouldn't you be using CMAKE_EXE_LINKER_FLAGS for adding linker flags? The variable you are using overrides the whole linker invocation and you have to take care of all paths and outputs on your own. If you are linking libraries, use CMAKE_SHARED_LIBRARY_C[XX]_FLAGS, after setting up CMP0018 policy. Also, don't forget -Wl Cheers, Vittorio -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake