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

Littlefield, Tyler tyler at tysdomain.com
Sun Feb 9 00:08:59 EST 2014


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.



More information about the CMake mailing list