Re: [CMake] CMake and shared|static/release|debug?

2014-11-18 Thread Dan Kegel
I'm facing the question of static myself now, porting a large automake
project to cmake.

I guess I'll mirror automake's practice of  having separate
--enable-static and --enable-shared settings, and allow both to be
built at once.
It's a bit ambiguous (which one gets tested?), but since I'm just
reproducing old behavior, that's probably ok.

It was tempting to make Static be a suffix on CMAKE_BUILD_TYPE, but
nobody seems to do that...?

On Sat, Feb 8, 2014 at 9:08 PM, Littlefield, Tyler ty...@tysdomain.com wrote:
 hello:
 thanks all for the help--I really appreciate it. that cleaned up my file
 quite a lot and was exactly what I was aiming for.
 Thanks again,


 On 2/5/2014 6:17 AM, Johannes Zarl wrote:

 Hi,

 On Tuesday, 4. February 2014, 23:41:55, Littlefield, Tyler wrote:

 I've tried this a few different ways and ran into issues. If someone
 wouldn't mind pointing out where I'm going wrong, I would appreciate it.
 (for example if there's a better way to do what I'm trying).

 It would help if you also included a textual description of the thing you
 want
 to achieve and your issues. Since the cmake compiler does not do what you
 want
 it to do, it is quite plausible that the people on this list having a good
 understanding of cmake will misinterpret your cmake code...

 That aside, as Jakub pointed out, it seems that you try to reimplement the
 CMAKE_BUILD_TYPE support on your own.

 As to the shared library stuff: CMake can already build shared and static
 libraries in the same build:

 set( MYLIB_SRCS mylibsource1.cxx mylibsource2.cxx)
 add_library( mylib-static STATIC ${MYLIB_SRCS})
 add_library( mylib-static SHARED ${MYLIB_SRCS})

 If you want to make it a choice, you could do it like this:

 set( BUILD_LIBTYPE SHARED CACHE STRING SHARED or STATIC )
 # enforce string in the gui:
 set_property(CACHE BUILD_LIBTYPE PROPERTY STRINGS SHARED STATIC)
 if ( NOT BUILD_LIBTYPE STREQUAL STATIC )
set ( BUILD_LIBTYPE SHARED CACHE STRING  FORCE)
 endif()

 add_library( mylib-static ${BUILD_LIBTYPE} ${MYLIB_SRCS})

 HTH,
Johannes



 --
 Take care,
 Ty
 http://tds-solutions.net
 He that will not reason is a bigot; he that cannot reason is a fool; he that
 dares not reason is a slave.

 --

 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://www.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:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] CMake and shared|static/release|debug?

2014-02-08 Thread Littlefield, Tyler

hello:
thanks all for the help--I really appreciate it. that cleaned up my file 
quite a lot and was exactly what I was aiming for.

Thanks again,

On 2/5/2014 6:17 AM, Johannes Zarl wrote:

Hi,

On Tuesday, 4. February 2014, 23:41:55, Littlefield, Tyler wrote:

I've tried this a few different ways and ran into issues. If someone
wouldn't mind pointing out where I'm going wrong, I would appreciate it.
(for example if there's a better way to do what I'm trying).

It would help if you also included a textual description of the thing you want
to achieve and your issues. Since the cmake compiler does not do what you want
it to do, it is quite plausible that the people on this list having a good
understanding of cmake will misinterpret your cmake code...

That aside, as Jakub pointed out, it seems that you try to reimplement the
CMAKE_BUILD_TYPE support on your own.

As to the shared library stuff: CMake can already build shared and static
libraries in the same build:

set( MYLIB_SRCS mylibsource1.cxx mylibsource2.cxx)
add_library( mylib-static STATIC ${MYLIB_SRCS})
add_library( mylib-static SHARED ${MYLIB_SRCS})

If you want to make it a choice, you could do it like this:

set( BUILD_LIBTYPE SHARED CACHE STRING SHARED or STATIC )
# enforce string in the gui:
set_property(CACHE BUILD_LIBTYPE PROPERTY STRINGS SHARED STATIC)
if ( NOT BUILD_LIBTYPE STREQUAL STATIC )
   set ( BUILD_LIBTYPE SHARED CACHE STRING  FORCE)
endif()

add_library( mylib-static ${BUILD_LIBTYPE} ${MYLIB_SRCS})

HTH,
   Johannes



--
Take care,
Ty
http://tds-solutions.net
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

--

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://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] CMake and shared|static/release|debug?

2014-02-05 Thread Johannes Zarl
Hi,

On Tuesday, 4. February 2014, 23:41:55, Littlefield, Tyler wrote:
 I've tried this a few different ways and ran into issues. If someone
 wouldn't mind pointing out where I'm going wrong, I would appreciate it.
 (for example if there's a better way to do what I'm trying).

It would help if you also included a textual description of the thing you want 
to achieve and your issues. Since the cmake compiler does not do what you want 
it to do, it is quite plausible that the people on this list having a good 
understanding of cmake will misinterpret your cmake code...

That aside, as Jakub pointed out, it seems that you try to reimplement the 
CMAKE_BUILD_TYPE support on your own.

As to the shared library stuff: CMake can already build shared and static 
libraries in the same build:

set( MYLIB_SRCS mylibsource1.cxx mylibsource2.cxx)
add_library( mylib-static STATIC ${MYLIB_SRCS})
add_library( mylib-static SHARED ${MYLIB_SRCS})

If you want to make it a choice, you could do it like this:

set( BUILD_LIBTYPE SHARED CACHE STRING SHARED or STATIC )
# enforce string in the gui:
set_property(CACHE BUILD_LIBTYPE PROPERTY STRINGS SHARED STATIC)
if ( NOT BUILD_LIBTYPE STREQUAL STATIC )
  set ( BUILD_LIBTYPE SHARED CACHE STRING  FORCE)
endif()

add_library( mylib-static ${BUILD_LIBTYPE} ${MYLIB_SRCS})

HTH,
  Johannes
-- 

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://www.cmake.org/mailman/listinfo/cmake


[CMake] CMake and shared|static/release|debug?

2014-02-04 Thread Littlefield, Tyler

Hello all:
I've tried this a few different ways and ran into issues. If someone 
wouldn't mind pointing out where I'm going wrong, I would appreciate it. 
(for example if there's a better way to do what I'm trying).


Thanks,

cmake_minimum_required(VERSION 2.8)
project(BLOXWEB)

#include additional modules
set(CMAKE_MODULE_PATH ${BLOXWEB_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

#set up our versioning info.
include(bloxwebVersion)
blox_version(MAJOR 0 MINOR 1 PATCH 0)

message(Configuring Bloxweb ${BLOXWEB_VERSION}.)
#set options
option(BUILD_STATIC build static library ON)
option(BUILD_SHARED build shared library OFF)
option(BUILD_DEBUG debug build ON)
option(BUILD_RELEASE build release OFF)

#locate our binary directories.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib cache)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib cache)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin cache)

#compiler flags
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic 
-Weffc++ cache)

set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} -O1 -ggdb cache)
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} -O2 -s cache)
set(BLOX_SOURCE_FILES src/header.cpp)

#source/include paths
include_directories(${BLOXWEB_SOURCE_DIR}/include)

if (BUILD_DEBUG AND BUILD_RELEASE)
message(You may not build debug and release at the same time.)
return(1)
endif()
if (BUILD_STATIC AND BUILD_SHARED)
message(You may not build static and shared at the same time.)
return(1)
endif()

if (BUILD_RELEASE)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
add_definitions(-DNDEBUG)
endif()
if (BUILD_DEBUG)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
endif()
if (BUILD_SHARED)
set(BUILD_SHARED_LIBS TRUE)
endif()

add_library(bloxweb ${BLOX_SOURCE_FILES})

--
Take care,
Ty
http://tds-solutions.net
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

--

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://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] CMake and shared|static/release|debug?

2014-02-04 Thread Jakub Zakrzewski
Hi.

CMake already has CMAKE_BUILD_TYPE I'd recommend using that instead of your 
own solution. I'm not aware of similar switch for static/shared, however in my 
opinion it should be done the same way the CMAKE_BUILD_TYPE works. You don't 
have to play in checking for invalid configurations. 

And you should probably take a look here, as it may give you better ideas: 
http://www.cmake.org/Wiki/CMake_Useful_Variables#Compilers_and_Tools


--
Gruesse,
Jakub


-Original Message-
From: CMake [mailto:cmake-boun...@cmake.org] On Behalf Of Littlefield, Tyler
Sent: Dienstag, 4. Februar 2014 23:42
To: cmake@cmake.org
Subject: [CMake] CMake and shared|static/release|debug?

Hello all:
I've tried this a few different ways and ran into issues. If someone wouldn't 
mind pointing out where I'm going wrong, I would appreciate it. 
(for example if there's a better way to do what I'm trying).

Thanks,

cmake_minimum_required(VERSION 2.8)
project(BLOXWEB)

#include additional modules
set(CMAKE_MODULE_PATH ${BLOXWEB_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

#set up our versioning info.
include(bloxwebVersion)
blox_version(MAJOR 0 MINOR 1 PATCH 0)

message(Configuring Bloxweb ${BLOXWEB_VERSION}.) #set options 
option(BUILD_STATIC build static library ON) option(BUILD_SHARED build 
shared library OFF) option(BUILD_DEBUG debug build ON) option(BUILD_RELEASE 
build release OFF)

#locate our binary directories.
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib cache) 
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib cache) 
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin cache)

#compiler flags
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic 
-Weffc++ cache)
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} -O1 -ggdb cache) 
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} -O2 -s cache) 
set(BLOX_SOURCE_FILES src/header.cpp)

#source/include paths
include_directories(${BLOXWEB_SOURCE_DIR}/include)

if (BUILD_DEBUG AND BUILD_RELEASE)
message(You may not build debug and release at the same time.)
return(1)
endif()
if (BUILD_STATIC AND BUILD_SHARED)
message(You may not build static and shared at the same time.)
return(1)
endif()

if (BUILD_RELEASE)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
add_definitions(-DNDEBUG)
endif()
if (BUILD_DEBUG)
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
endif()
if (BUILD_SHARED)
set(BUILD_SHARED_LIBS TRUE)
endif()

add_library(bloxweb ${BLOX_SOURCE_FILES})

--
Take care,
Ty
http://tds-solutions.net
He that will not reason is a bigot; he that cannot reason is a fool; he that 
dares not reason is a slave.

-- 

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://www.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:
http://www.cmake.org/mailman/listinfo/cmake