Re: [CMake] Static Library output problem

2011-11-12 Thread Michael Hertling
On 11/11/2011 03:42 PM, Romain LEGUAY wrote:
> Ok thanks for your quick answers! It works perfectly now!
> 
> Why don't we have just one variables for the library?
> 
> With set_target_properties, we can define for each library the path.

Because

(1) ADD_LIBRARY() might lack the SHARED/STATIC keyword, and the user
can decide which type of library is built via the BUILD_SHARED_LIBS
variable, so an ADD_LIBRARY() command can be unalteredly used to
build a shared library as well as a static one, and

(2) on *nix, the outcome of ADD_LIBRARY(... SHARED ...) is a LIBRARY
target whereas on Windows, the DLL part is a RUNTIME target, and the
accompanying import library is an ARCHIVE target.

For these reasons, the same ADD_LIBRARY() command - i.e., the same
target - might generate different types of libraries, so there is
a need to specify the respective *_OUTPUT_DIRECTORY individually.

Regards,

Michael

> Le 11/11/2011 15:38, Andreas Pakulat a écrit :
>> On 11.11.11 15:18:05, Romain LEGUAY wrote:
>>> Hello everyone!
>>> First, I need to thank you all the CMake developers for their
>>> awesome work!!!
>>>
>>> I try to build a static and a shared libraries. I set the
>>> LIBRARY_OUTPUT_DIRECTORY for each library target like this:
>> See the documentation for the LIBRARY_OUTPUT_DIRECTORY, it only applies
>> to shared libraries on non-dll platforms (*nix usually). For a static
>> library you need to set ARCHIVE_OUTPUT_DIRECTORY.
>>
>> Andreas
--

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] Static Library output problem

2011-11-11 Thread Romain LEGUAY

Ok thanks for your quick answers! It works perfectly now!

Why don't we have just one variables for the library?

With set_target_properties, we can define for each library the path.

Romain


Le 11/11/2011 15:38, Andreas Pakulat a écrit :

On 11.11.11 15:18:05, Romain LEGUAY wrote:

Hello everyone!
First, I need to thank you all the CMake developers for their
awesome work!!!

I try to build a static and a shared libraries. I set the
LIBRARY_OUTPUT_DIRECTORY for each library target like this:

See the documentation for the LIBRARY_OUTPUT_DIRECTORY, it only applies
to shared libraries on non-dll platforms (*nix usually). For a static
library you need to set ARCHIVE_OUTPUT_DIRECTORY.

Andreas

--

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


--

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] Static Library output problem

2011-11-11 Thread Andreas Pakulat
On 11.11.11 15:18:05, Romain LEGUAY wrote:
> Hello everyone!
> First, I need to thank you all the CMake developers for their
> awesome work!!!
> 
> I try to build a static and a shared libraries. I set the
> LIBRARY_OUTPUT_DIRECTORY for each library target like this:

See the documentation for the LIBRARY_OUTPUT_DIRECTORY, it only applies
to shared libraries on non-dll platforms (*nix usually). For a static
library you need to set ARCHIVE_OUTPUT_DIRECTORY.

Andreas

--

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] Static Library output problem

2011-11-11 Thread Michael Wild
On 11/11/2011 03:18 PM, Romain LEGUAY wrote:
> Hello everyone!
> First, I need to thank you all the CMake developers for their awesome
> work!!!
> 
> I try to build a static and a shared libraries. I set the
> LIBRARY_OUTPUT_DIRECTORY for each library target like this:
> 
> set_target_properties(${sharedLib} PROPERTIES
>   LIBRARY_OUTPUT_DIRECTORY
>  
> ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE})
> 
> set_target_properties(${staticLib} PROPERTIES
>   LIBRARY_OUTPUT_DIRECTORY
>  
> ${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE})
> 
> 
> The shared library is built in the correct directory but the static is
> built in PROJECT_BINARY_DIR.
> I try to switch the order of the set_target_properties method but no
> changes.
> I don't why it doesn't work.
> 
> Did anyone have any ideas?
> 
> I attached my CMakeLists.txt file.
> 
> Thanks,
> Romain
> 
> PS: I'm on Ubuntu 11.10 64bits, with cmake 2.8.5 (installed from the deb
> package).

For static libraries, all the variables and properties use the ARCHIVE
name (e.g. ARCHIVE_OUTPUT_DIRECTORY).

HTH

Michael

--

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] Static Library output problem

2011-11-11 Thread Romain LEGUAY

Hello everyone!
First, I need to thank you all the CMake developers for their awesome 
work!!!


I try to build a static and a shared libraries. I set the 
LIBRARY_OUTPUT_DIRECTORY for each library target like this:


set_target_properties(${sharedLib} PROPERTIES
  LIBRARY_OUTPUT_DIRECTORY
  
${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE})

set_target_properties(${staticLib} PROPERTIES
  LIBRARY_OUTPUT_DIRECTORY
  
${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE})


The shared library is built in the correct directory but the static is 
built in PROJECT_BINARY_DIR.
I try to switch the order of the set_target_properties method but no 
changes.

I don't why it doesn't work.

Did anyone have any ideas?

I attached my CMakeLists.txt file.

Thanks,
Romain

PS: I'm on Ubuntu 11.10 64bits, with cmake 2.8.5 (installed from the deb 
package).
cmake_minimum_required(VERSION 2.8)

project(XmlParser)

find_package(CxxTest)

IF(CYGWIN)
  unset(WIN32)
ENDIF()

# The version number
set(XmlParser_VERSION_MAJOR 1)
set(XmlParser_VERSION_MINOR 0)
set(XmlParser_VERSION_REVISION b)
set(XmlParser_VERSION 
  
"${XmlParser_VERSION_MAJOR}.${XmlParser_VERSION_MINOR}${XmlParser_VERSION_REVISION}")

# configure a header file to pass some of the CMake settings
# to the source code
configure_file(
  "${PROJECT_SOURCE_DIR}/include/XmlParserConfig.h.in"
  "${PROJECT_BINARY_DIR}/include/XmlParserConfig.h"
)

include_directories(include ${PROJECT_BINARY_DIR}/include)

file(GLOB
  SOURCE_FILES
  src/*.cpp
  include/template/*.hpp
)

file(GLOB
  INCLUDE_FILES
  include/*.h
  "${PROJECT_BINARY_DIR}"/include/*.h
)

set(xmlParserSharedLib xmlParser)
set(xmlParserStaticLib xmlParserStatic)

add_library(${xmlParserStaticLib}
STATIC
${SOURCE_FILES})
add_library(${xmlParserSharedLib}
SHARED
${SOURCE_FILES})

set_target_properties(${xmlParserStaticLib} PROPERTIES
  LIBRARY_OUTPUT_DIRECTORY 
  
${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE})
set_target_properties(${xmlParserSharedLib} PROPERTIES
  LIBRARY_OUTPUT_DIRECTORY 
  
${PROJECT_BINARY_DIR}/lib/${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}/${CMAKE_BUILD_TYPE})

#install(TARGETS ${xmlParserSharedLib} ${xmlParserStaticLib} DESTINATION lib)
#install(FILES ${INCLUDE_FILES} DESTINATION include)

if(CXXTEST_FOUND)
  set(xmlParser_test_include "${PROJECT_SOURCE_DIR}/unitary-test/include")
  set(xmlParser_test_src "unitary-test/src")
  set(xmlParser_test_build "unitary-test/build")
  set(CXXTEST_USE_PYTHON TRUE)
  include_directories(${CXXTEST_INCLUDE_DIR})
  set(XmlElementTest ${xmlParser_test_build}/XmlElementTest)
  CXXTEST_ADD_TEST(${XmlElementTest} ${xmlParser_test_src}/XmlElementTest.cpp 
${xmlParser_test_include}/XmlElementTest.h)
  target_link_libraries(${XmlElementTest} ${xmlParserStaticLib})
endif()
--

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