Hi Rodrigo,

Glad that it is working for you now. I just wanted to mention that I never
had to set the language as properties to the source files since cmake
detects it from the suffix of the source files you list, or at least I
never had a case where the language was not properly detected.

Other than that I agree with Hendrik's suggestions as well!

Cheers,
Angeliki






On Wed, Aug 6, 2014 at 5:54 AM, Hendrik Sattler <p...@hendrik-sattler.de>
wrote:

> Hi,
>
> -lm does not belong to CMAKE_CXX_FLAGS as it is a linker option to link
> libm.
> Use
> target_link_libraries(protpred-Gromacs-NSGA2 m)
> instead. (Don't search for libm, the linker knows where it is.)
>
> It is also more common to use a variable for the list of source files.
> That would make it also possible to set the compile language for all files
> in one command without listing files twice.
>
> Adding headers and not just .c/.cpp/.cxx files makes it easier when using
> an IDE.
>
>
> On 5. August 2014 22:13:54 MESZ, Rodrigo Faccioli <
> rodrigo.facci...@gmail.com> wrote:
> >Hi,
> >
> >I am thankfull for all help. Now, it is working :-)
> >
> >Radovan, thank you to try to run and your comments.
> >
> >My CMakeList.txt is showed below. I would like to know about best
> >practice
> >to make a CMakeList. If agree, I will compile others executables of my
> >project based on how I compiled this executable. In [1] contains my
> >full
> >project.
> >
> >cmake_minimum_required(VERSION 2.8)
> >
> ># project Information
> >project(2pg_cartesian)
> >set(PROJECT_VERSION "1.0")
> >
> ># Set compiler flags
> >SET ( CMAKE_CXX_FLAGS "-lm -pedantic")
> >
> >#Set CXX compiler for all files below
> >set_source_files_properties(include/LoadConfig.h PROPERTIES LANGUAGE
> >CXX )
> >set_source_files_properties(src/protpred-Gromacs-NSGA2.c  PROPERTIES
> >LANGUAGE CXX )
> >set_source_files_properties(src/LoadConfig.cpp  PROPERTIES LANGUAGE CXX
> >)
> >set_source_files_properties(src/ea_mono.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/topology.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/pdbio.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/protein.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/futil.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/pdbatom.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/messages.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/topologyio.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/topologylib.c  PROPERTIES LANGUAGE CXX
> >)
> >set_source_files_properties(src/randomlib.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/vector_math.c  PROPERTIES LANGUAGE CXX
> >)
> >set_source_files_properties(src/string_owner.c  PROPERTIES LANGUAGE CXX
> >)
> >set_source_files_properties(src/math_owner.c   PROPERTIES LANGUAGE CXX
> >)
> >set_source_files_properties(src/osutil.c   PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/load_parameters.c  PROPERTIES LANGUAGE
> >CXX )
> >set_source_files_properties(src/objective.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/aminoacids.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/aminoacids_io.c  PROPERTIES LANGUAGE
> >CXX )
> >set_source_files_properties(src/populationio.c  PROPERTIES LANGUAGE CXX
> >)
> >set_source_files_properties(src/rotation.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/solution.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/gromacs_objectives.c  PROPERTIES
> >LANGUAGE
> >CXX )
> >set_source_files_properties(src/solutionio.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/algorithms.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/ea_nsga2.c  PROPERTIES LANGUAGE CXX )
> >set_source_files_properties(src/dominance.c PROPERTIES LANGUAGE CXX )
> >
> ># set include
> >include_directories(include)
> >
> ># add libries
> >add_library(2PG-NSGA2_lib STATIC
> >src/LoadConfig.cpp
> >src/ea_mono.c
> >src/topology.c
> >src/pdbio.c
> >src/protein.c
> >src/futil.c
> >src/pdbatom.c
> >src/messages.c
> >src/topologyio.c
> >src/topologylib.c
> >src/randomlib.c
> >src/vector_math.c
> >src/string_owner.c
> >src/math_owner.c
> >src/osutil.c
> >src/load_parameters.c
> >src/objective.c
> >src/aminoacids.c
> >src/aminoacids_io.c
> >src/populationio.c
> >src/rotation.c
> >src/solution.c
> >src/gromacs_objectives.c
> >src/solutionio.c
> >src/algorithms.c
> >src/ea_nsga2.c
> >src/dominance.c
> >) #end of 2PG-NSGA2_lib
> >
> ># add target
> >add_executable(protpred-Gromacs-NSGA2 src/protpred-Gromacs-NSGA2.c)
> >target_link_libraries(protpred-Gromacs-NSGA2 2PG-NSGA2_lib)
> >
> ># install
> >install(TARGETS protpred-Gromacs-NSGA2 DESTINATION bin)
> >
> >[1] https://dl.dropboxusercontent.com/u/4270818/2pg_cartesian_cmake.zip
> >
> >Best regards,
> >
> >--
> >Rodrigo Antonio Faccioli, Ph.D
> >Development Software for Structural Bioinformatics
> >Barao de Maua University
> >University of Sao Paulo
> >Lindedin - br.linkedin.com/pub/rodrigo-antonio-faccioli/7/589/a5/
> >Curriculum Lattes - http://lattes.cnpq.br/1025157978990218
> >
> >
> >On Tue, Aug 5, 2014 at 3:39 PM, radovan bast <b...@kth.se> wrote:
> >
> >> dear Rodrigo,
> >>
> >> i tried it but ran into many other problems in the source, not cmake.
> >>
> >> but also some cmake suggestions:
> >> - list the language(s) that the project uses
> >> - the c99 flag is not a definition but a compiler flag, use
> >> CMAKE_CXX_FLAGS_... for portability
> >> - "ALL" is not a good library name
> >> - i recommend to not glob sources but to list them explicitly, there
> >are
> >> several discussions on the net
> >>   which explain why if you search for the topic
> >>
> >> good luck!
> >>   radovan
> >>
> >>
> >> On Tue, Aug 5, 2014 at 5:08 PM, Rodrigo Faccioli <
> >> rodrigo.facci...@gmail.com> wrote:
> >>
> >>> Hi,
> >>>
> >>> Thanks Angeliki and Bill for your attentation.
> >>>
> >>> I have updated my CMakeList.txt based on your post. Below my
> >>> CMakeList.txt is showed.
> >>>
> >>> cmake_minimum_required(VERSION 2.8)
> >>> # project Information
> >>> project(2pg_cartesian)
> >>> set(PROJECT_VERSION "1.0")
> >>> # add definitions to compiler
> >>> add_definitions(-std=c99)
> >>> # get all files under directory src
> >>> file(GLOB SRC_FILES "src/*.c")
> >>> # set include
> >>> include_directories(include)
> >>> # added libries
> >>> add_library(ALL STATIC ${SRC_FILES})
> >>> # add target
> >>> add_executable(protpred-Gromacs-NSGA2 src/protpred-Gromacs-NSGA2.c)
> >>> target_link_libraries(protpred-Gromacs-NSGA2 ALL)
> >>>
> >>> Unfortunatelly, I have received error messages as cited below:
> >>> faccioli@faccioli:~/Downloads/2pg_cartesian/build$ make
> >>> Scanning dependencies of target ALL
> >>> [  2%] Building C object
> >CMakeFiles/ALL.dir/src/protpred-Gromacs-NSGA2.c.o
> >>> [  5%] Building C object CMakeFiles/ALL.dir/src/ea_mono.c.o
> >>> [  7%] Building C object CMakeFiles/ALL.dir/src/topologyio.c.o
> >>> [ 10%] Building C object CMakeFiles/ALL.dir/src/aminoacids.c.o
> >>> [ 12%] Building C object CMakeFiles/ALL.dir/src/populationio.c.o
> >>> [ 15%] Building C object CMakeFiles/ALL.dir/src/osutil.c.o
> >>> [ 17%] Building C object CMakeFiles/ALL.dir/src/aminoacids_io.c.o
> >>> [ 20%] Building C object
> >>>
>
> >CMakeFiles/ALL.dir/src/protpred-Gromacs-Sort_Method_Files_by_Front_Dominance.c.o
> >>> [ 23%] Building C object CMakeFiles/ALL.dir/src/pdbio.c.o
> >>> [ 25%] Building C object CMakeFiles/ALL.dir/src/solution.c.o
> >>> [ 28%] Building C object CMakeFiles/ALL.dir/src/vector_math.c.o
> >>> [ 30%] Building C object CMakeFiles/ALL.dir/src/math_owner.c.o
> >>> [ 33%] Building C object CMakeFiles/ALL.dir/src/protein.c.o
> >>> [ 35%] Building C object CMakeFiles/ALL.dir/src/load_parameters.c.o
> >>> In file included from
> >>> /home/faccioli/Downloads/2pg_cartesian/src/load_parameters.c:7:0:
> >>> /home/faccioli/Downloads/2pg_cartesian/include/LoadConfig.h:1:18:
> >fatal
> >>> error: string: Arquivo ou diretório não encontrado
> >>> compilation terminated.
> >>> make[2]: ** [CMakeFiles/ALL.dir/src/load_parameters.c.o] Erro 1
> >>> make[1]: ** [CMakeFiles/ALL.dir/all] Erro 2
> >>> make: ** [all] Erro 2
> >>> faccioli@faccioli:~/Downloads/2pg_cartesian/build$
> >>>
> >>> I did not understand what mistakes I have done since all files share
> >same
> >>> structure of directory. In [1] is my project completly. If prefer I
> >can
> >>> send its github repository.
> >>>
> >>> I appreciate any help.
> >>>
> >>> Best regards,
> >>>
> >>> [1]
> >https://dl.dropboxusercontent.com/u/4270818/2pg_cartesian_cmake.zip
> >>>
> >>>
> >>> --
> >>> Rodrigo Antonio Faccioli, Ph.D
> >>> Development Software for Structural Bioinformatics
> >>> Barao de Maua University
> >>> University of Sao Paulo
> >>> Lindedin - br.linkedin.com/pub/rodrigo-antonio-faccioli/7/589/a5/
> >>> Curriculum Lattes - http://lattes.cnpq.br/1025157978990218
> >>>
> >>>
> >>> On Mon, Aug 4, 2014 at 12:54 PM, Bill Hoffman
> ><bill.hoff...@kitware.com>
> >>> wrote:
> >>>
> >>>> On 8/4/2014 10:26 AM, Rodrigo Faccioli wrote:
> >>>>
> >>>>> protpred-Gromacs-NSGA2.c:(.text+0x1e): undefined reference to
> >>>>> `display_msg'
> >>>>> protpred-Gromacs-NSGA2.c:(.text+0x3e): undefined reference to
> >>>>> `load_parameters_from_file'
> >>>>> protpred-Gromacs-NSGA2.c:(.text+0x58): undefined reference to
> >>>>> `ea_nsga2'
> >>>>> protpred-Gromacs-NSGA2.c:(.text+0x64): undefined reference to
> >>>>> `fatal_error'
> >>>>> protpred-Gromacs-NSGA2.c:(.text+0x73): undefined reference to
> >>>>> `deAllocateload_parameters'
> >>>>> protpred-Gromacs-NSGA2.c:(.text+0x7d): undefined reference to
> >>>>> `display_msg'
> >>>>>
> >>>> You have to find out where these symbols are defined.  If you have
> >a
> >>>> working Makefile version use nm and grep to find the places.   You
> >can also
> >>>> grep your source tree.  You are either missing a source file, or a
> >-D
> >>>> option.
> >>>>
> >>>> Another approach is to run make VERBOSE=1 and compare the build
> >command
> >>>> lines to your Makefile build.
> >>>>
> >>>> -Bill
> >>>>
> >>>> --
> >>>>
> >>>> 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
> >>>
> >>
> >>
> >>
> >> --
> >> # PDC Center for High Performance Computing &
> >> # Department of Theoretical Chemistry and Biology
> >> # Royal Institute of Technology, Stockholm
> >> # +46-8-790-6628
> >>
> >
> >
> >------------------------------------------------------------------------
>
> --
>
> 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

Reply via email to