Re: [CMake] libc++ usage in CMake with Clang?

2018-08-20 Thread Thompson, KT
I'm also interested in the answer to Robert's question.  I've been using

  set( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -stdlib=libc++")

but it seems like there should be a more elegant approach.

-tk

-Original Message-
From: CMake  On Behalf Of Robert Dailey
Sent: Monday, August 20, 2018 11:48 AM
To: CMake 
Subject: [CMake] libc++ usage in CMake with Clang?

Is the only way to use libc++ to muck with compile flags? Or is there a proper 
find module for this or something? Is there a more CMake-esque way of 
specifying the STL library to use with the toolchain?
-- 

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] libc++ usage in CMake with Clang?

2018-08-20 Thread Stephen McDowell
Good question. The only official thing I could find that is _somewhat_
related is this:
https://cmake.org/cmake/help/latest/variable/CMAKE_ANDROID_STL_TYPE.html#variable:CMAKE_ANDROID_STL_TYPE

Doesn't really help if you aren't targeting Android though

On Mon, Aug 20, 2018, 10:48 AM Robert Dailey 
wrote:

> Is the only way to use libc++ to muck with compile flags? Or is there
> a proper find module for this or something? Is there a more
> CMake-esque way of specifying the STL library to use with the
> toolchain?
> --
>
> 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


[CMake] libc++ usage in CMake with Clang?

2018-08-20 Thread Robert Dailey
Is the only way to use libc++ to muck with compile flags? Or is there
a proper find module for this or something? Is there a more
CMake-esque way of specifying the STL library to use with the
toolchain?
-- 

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] [cmake-developers] RfD: deprecate link_directories() and link_libraries()

2018-08-20 Thread Rolf Eike Beer
Am Montag, 20. August 2018, 19:10:57 CEST schrieb Brad King:
> On 08/15/2018 01:30 PM, Rolf Eike Beer wrote:
> > My dislike against these functions is probably known, and now I would like
> > to bring this to a new level: I would like to formally deprecate these
> > functions. I don't think they serve any useful purpose anymore, given
> > that now even the pkg-config module can (and does) return absolute paths
> > to the libraries.
> What harm does their presence cause?
> 
> Please ask on the user list to see if people are using them.
> 
> I suspect they may be used by some projects to link to special runtime
> libraries when cross-compiling.  We'd need to make sure there is a
> better way for all such use cases before deprecating the commands.

I have only seen this commands in failed attempts to convert Makefiles to 
CMake without using the proper methods of calling find_library(). And then 
showing up here or in #cmake and complaining that it breaks.

So, has anyone an example where these are still needed with CMake 3.12 for 
anything that _can't_ be done properly?

Eike


signature.asc
Description: This is a digitally signed message part.
-- 

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] Problem with creating shared library

2018-08-20 Thread Damir Porobic
Hi Eric,


yes, this is the project. I have pushed my current state to this branch 
https://github.com/DamirPorobic/kImageAnnotator/tree/sharedLibTestBranch


I've tried also without the generate_export_headers (cleaned everything up 
before trying out) but I get the same result.


KImageAnnotator::KImageAnnotator(QPixmap const&)should be exposed by the 
handwritten file, that's true, I think I got something mixed up there and I 
don't actually need the generate_export_headers, but as said, even without the 
line, it's not working.


Cheers,

Damir


From: Eric Noulard 
Sent: Sunday, August 19, 2018 22:44
To: Damir Porobic
Cc: smanc...@jlab.org; CMake Mailinglist
Subject: Re: [CMake] Problem with creating shared library

Hi Damir,

May be the issue has nothing to do with the way you build the exported 
<>Config.cmake files.
Since may be some nasty detail slipped in, could you tell us if the project is 
public.
It looks like this one:
https://github.com/DamirPorobic/kImageAnnotator

may be you can push a branch that contains the exact thing that fails on your 
side and it may be easier to review the detail?

on the master of this repo there does not seem to have any "example" dir.

However you already have hand written header file:
https://github.com/DamirPorobic/kImageAnnotator/blob/master/src/gui/KImageAnnotator.h

which has the very same name as the "exported header you generate":
generate_export_header(kImageAnnotator
EXPORT_MACRO_NAME KIMAGEANNOTATOR_API
EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/include/KImageAnnotator.h
)

so may be
KImageAnnotator::KImageAnnotator(QPixmap const&)
is exposed by the hand-written file and not by the generated one so
that your unit test links ok but your "example" does not ?

Did you check the content of the generated header file?








Le dim. 19 août 2018 à 15:17, Damir Porobic 
mailto:damir_poro...@live.com>> a écrit :

Thanks Sebastián for providing those links!


I've followed the second link that you've provided but somehow I'm still 
running into issue.


I've changed the directory structure to this:

- kImageAnnotator
- cmake
- kImageAnnotator-config.cmake.in
- example
- main.cpp
- CMakeLists.txt
- include
- kImageAnnotator
- KImageAnnotator.h // the main api header
- src
- KImageAnnotator.cpp
- "And all other .cpp and .h files"
- CMakeLists.txt
- CMakeLists.txt

src/CMakeList.txt looks like this:
add_library(kImageAnnotator ${kimageannotator_SRCS} 
${CMAKE_SOURCE_DIR}/include/kImageAnnotator/KImageAnnotator.h)

add_library(kImageAnnotator::kImageAnnotator ALIAS kImageAnnotator)

option(BUILD_SHARED_LIBS "Build shared library" ON)
include(GenerateExportHeader)

generate_export_header(kImageAnnotator
EXPORT_MACRO_NAME KIMAGEANNOTATOR_API
EXPORT_FILE_NAME ${CMAKE_BINARY_DIR}/include/KImageAnnotator.h
)

target_include_directories(kImageAnnotator
PUBLIC
$
$
$
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

set_target_properties(kImageAnnotator PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Widgets)

find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS CoreAddons I18n 
WidgetsAddons)

target_link_libraries(kImageAnnotator Qt5::Widgets KF5::CoreAddons KF5::I18n 
KF5::WidgetsAddons)

include(GNUInstallDirs)

install(TARGETS kImageAnnotator
EXPORT kImageAnnotator-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${LIBLEGACY_INCLUDE_DIRS}
)

install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/kImageAnnotator
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(EXPORT kImageAnnotator-targets
FILE kImageAnnotator-targets.cmake
NAMESPACE kImageAnnotator::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kImageAnnotator
)


include(CMakePackageConfigHelpers)

configure_package_config_file(

${CMAKE_SOURCE_DIR}/cmake/kImageAnnotator-config.cmake.in
${CMAKE_BINARY_DIR}/cmake/kImageAnnotator-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kImageAnnotator
)

write_basic_package_version_file(
${CMAKE_BINARY_DIR}/cmake/kImageAnnotator-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

install(FILES
${CMAKE_BINARY_DIR}/cmake/kImageAnnotator-config.cmake
${CMAKE_BINARY_DIR}/cmake/kImageAnnotator-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kImageAnnotator
)

export(EXPORT kImageAnnotator-targets
FILE ${CMAKE_BINAR

Re: [CMake] MPI: Undefined symbol

2018-08-20 Thread Rafael Sadowski
On Mon Aug 20, 2018 at 04:24:07PM +0200, Florian Lindner wrote:
> Hello,
> 
> copied from a working MPI CMakeLists.txt:
> 
> find_package(MPI REQUIRED)

https://cmake.org/cmake/help/v3.0/module/FindMPI.html

MPI__FOUND   TRUE if FindMPI found MPI flags for 
MPI__COMPILERMPI Compiler wrapper for 
MPI__COMPILE_FLAGS   Compilation flags for MPI programs
MPI__INCLUDE_PATHInclude path(s) for MPI header
MPI__LINK_FLAGS  Linking flags for MPI programs
MPI__LIBRARIES   All libraries to link MPI programs against

Looks like you forgot .

> include_directories(${MPI_INCLUDE_PATH})
> set(COMPILE_FLAGS  ${COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
> set(LINK_FLAGS ${LINK_FLAGS} ${MPI_LINK_FLAGS})
> 
> 
> add_executable(StructureSolverParallel
>   "StructureSolver_Parallel/structureDataDisplay.cpp"
>   "StructureSolver_Parallel/StructureSolver.cpp"
>   "StructureSolver_Parallel/structureComputeSolution.cpp")
> 
> target_link_libraries(StructureSolverParallel PUBLIC ${PRECICE_LIBRARY})
> target_link_libraries(StructureSolverParallel PUBLIC ${MPI_LBRARIES})
> 
> configuration runs smooth:
> 
> % cmake -DMPI_CXX_COMPILER=/opt/mpich/bin/mpicxx 
> -DMPI_C_COMPILER=/opt/mpich/bin/mpicc . && make   
> -- The CXX compiler identification is GNU 8.2.0
> [...]
> -- Found MPI_CXX: /opt/mpich/lib/libmpicxx.so (found version "3.1") 
> -- Found MPI: TRUE (found version "3.1")  
> 
> make however:
> 
> [ 69%] Linking CXX executable StructureSolverParallel
> /usr/bin/cmake -E cmake_link_script 
> CMakeFiles/StructureSolverParallel.dir/link.txt --verbose=1
> /usr/bin/c++   -Wall -Wextra -Wno-unused-parameter -g   
> CMakeFiles/StructureSolverParallel.dir/StructureSolver_Parallel/structureDataDisplay.cpp.o
>  
> CMakeFiles/StructureSolverParallel.dir/StructureSolver_Parallel/StructureSolver.cpp.o
>  
> CMakeFiles/StructureSolverParallel.dir/StructureSolver_Parallel/structureComputeSolution.cpp.o
>   -o StructureSolverParallel /home/lindnefn/precice/build/last/libprecice.so 
> /usr/bin/ld: 
> CMakeFiles/StructureSolverParallel.dir/StructureSolver_Parallel/StructureSolver.cpp.o:
>  undefined reference to symbol 'MPI_Init'
> /usr/bin/ld: /opt/mpich/lib/libmpi.so.12: error adding symbols: DSO missing 
> from command line
> 
> when I just take the last command line and -lmpi to it, it works.
> 
> What could be missing there in CMakeLists?
> 
> Thanks,
> Florian
> 
> -- 
> 
> 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


[CMake] MPI: Undefined symbol

2018-08-20 Thread Florian Lindner
Hello,

copied from a working MPI CMakeLists.txt:

find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
set(COMPILE_FLAGS  ${COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
set(LINK_FLAGS ${LINK_FLAGS} ${MPI_LINK_FLAGS})


add_executable(StructureSolverParallel
  "StructureSolver_Parallel/structureDataDisplay.cpp"
  "StructureSolver_Parallel/StructureSolver.cpp"
  "StructureSolver_Parallel/structureComputeSolution.cpp")

target_link_libraries(StructureSolverParallel PUBLIC ${PRECICE_LIBRARY})
target_link_libraries(StructureSolverParallel PUBLIC ${MPI_LBRARIES})

configuration runs smooth:

% cmake -DMPI_CXX_COMPILER=/opt/mpich/bin/mpicxx 
-DMPI_C_COMPILER=/opt/mpich/bin/mpicc . && make   
-- The CXX compiler identification is GNU 8.2.0
[...]
-- Found MPI_CXX: /opt/mpich/lib/libmpicxx.so (found version "3.1") 
-- Found MPI: TRUE (found version "3.1")  

make however:

[ 69%] Linking CXX executable StructureSolverParallel
/usr/bin/cmake -E cmake_link_script 
CMakeFiles/StructureSolverParallel.dir/link.txt --verbose=1
/usr/bin/c++   -Wall -Wextra -Wno-unused-parameter -g   
CMakeFiles/StructureSolverParallel.dir/StructureSolver_Parallel/structureDataDisplay.cpp.o
 
CMakeFiles/StructureSolverParallel.dir/StructureSolver_Parallel/StructureSolver.cpp.o
 
CMakeFiles/StructureSolverParallel.dir/StructureSolver_Parallel/structureComputeSolution.cpp.o
  -o StructureSolverParallel /home/lindnefn/precice/build/last/libprecice.so 
/usr/bin/ld: 
CMakeFiles/StructureSolverParallel.dir/StructureSolver_Parallel/StructureSolver.cpp.o:
 undefined reference to symbol 'MPI_Init'
/usr/bin/ld: /opt/mpich/lib/libmpi.so.12: error adding symbols: DSO missing 
from command line

when I just take the last command line and -lmpi to it, it works.

What could be missing there in CMakeLists?

Thanks,
Florian

-- 

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