<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 29, 2014 at 1:48 AM, Domen Vrankar <span dir="ltr"><<a href="mailto:domen.vrankar@gmail.com" target="_blank">domen.vrankar@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I was curious and I looked a bit further:<br>
<a href="http://www.cmake.org/cmake/help/v3.0/command/add_library.html" target="_blank">http://www.cmake.org/cmake/help/v3.0/command/add_library.html</a> has a<br>
OBJECT target that perhaps you could use instead of static library.<br>
<br></blockquote><div>referencing objects is kinda messy, was actually cleaner to just copy things; I already did it for a whole slew of files so I could compile .c as C/C++/CLI ... but needed other compiler options; ended up copying almost the whole tree to ${cmake_binary_dir}/(subst/.c/.cpp/) </div><div>because I couldn't set compile properties per project only per source....</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<a href="http://www.cmake.org/cmake/help/v3.0/command/set_property.html" target="_blank">http://www.cmake.org/cmake/help/v3.0/command/set_property.html</a> also<br>
has a SOURCE option that I haven't mentioned before because I'm not<br>
certain how to produce two differently named .o files but maybe you'll<br>
be able to figure that out...<br>
<br></blockquote><div><br></div><div>That works, but it only applies to the name of the source; if you don't have differntly named sources it doesn't help; and I think that's the one I used in the first place....</div><div> </div><div>----</div><div>and as a related note; is better to make the generated output into binary dir; if into source_dir will just mess up source control and people will commit generated sources....</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Regards,<br>
Domen<br>
<div class=""><div class="h5"><br>
<br>
2014-11-29 10:31 GMT+01:00 Domen Vrankar <<a href="mailto:domen.vrankar@gmail.com">domen.vrankar@gmail.com</a>>:<br>
> Hi,<br>
><br>
> I haven't tested this but I think you could write something like this:<br>
><br>
> add_library(test_single test.c)<br>
> set_property(<br>
>    TARGET test_single<br>
>    PROPERTY COMPILE_DEFINITIONS DOUBLE=some_val<br>
> )<br>
> add_library(test_double test.c)<br>
> set_property(<br>
>    TARGET test_double<br>
>    PROPERTY COMPILE_DEFINITIONS DOUBLE=some_other_val<br>
> )<br>
><br></div></div></blockquote><div><br></div><div>wouldn't be included in a single library, and you'd have to know later to include 2 libs, or maintain a varible that's a list of libs...</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">
> and then link the static libraries to an executable.<br>
><br>
> As far as I know you could also use<br>
> set_target_properties(test_single PROPERTIES COMPILE_DEFINITIONS<br>
> DOUBLE=some_val)<br>
> but I'm not certain what the difference is... Probably back compatibility...<br>
><br>
> Hope this helps,<br>
> Domen<br>
><br>
><br>
><br>
> 2014-11-29 9:27 GMT+01:00 Zhang Xianyi <<a href="mailto:traits.zhang@gmail.com">traits.zhang@gmail.com</a>>:<br>
>> Hi Decker,<br>
>><br>
>> Thank you for the answer.<br>
>><br>
>> If I want to debug test_double, the debugger will refer to<br>
>> ${CMAKE_BINARY_DIR}/test_double.c.<br>
>> I am not sure it is appropriate to debug a generated file.<br>
>><br>
>><br>
>> Xianyi<br>
>><br>
>> 2014-11-28 23:03 GMT+08:00 J Decker <<a href="mailto:d3ck0r@gmail.com">d3ck0r@gmail.com</a>>:<br>
>>><br>
>>><br>
>>><br>
>>> On Fri, Nov 28, 2014 at 1:29 AM, Zhang Xianyi <<a href="mailto:traits.zhang@gmail.com">traits.zhang@gmail.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> Hi,<br>
>>>><br>
>>>> I want to use cmake for a library which supports different floating point<br>
>>>> precision.<br>
>>>><br>
>>>> In Makefile, I used $(*F)  to generate the different function name.<br>
>>>><br>
>>>> Could I use $(*F) in cmake?<br>
>>>><br>
>>>><br>
>>>> ==================<br>
>>>><br>
>>>> test.c<br>
>>>><br>
>>>> ===============<br>
>>>><br>
>>>> #ifdef DOUBLE<br>
>>>><br>
>>>> #define TYPE double<br>
>>>><br>
>>>> #else<br>
>>>><br>
>>>> #define TYPE float<br>
>>>><br>
>>>> #endif<br>
>>>><br>
>>>><br>
>>>> void CNAME(TYPE * a)<br>
>>>><br>
>>>> {<br>
>>>><br>
>>>>   a[0]=1.0;<br>
>>>><br>
>>>> }<br>
>>>><br>
>>>><br>
>>><br>
>>> CMakeLists.txt<br>
>>> ====================<br>
>>>  cmake_minimum_required(VERSION 2.8)<br>
>>><br>
>>>        add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/test_double.c<br>
>>>                            DEPENDS test.c<br>
>>>                            COMMAND ${CMAKE_COMMAND} -E copy_if_different<br>
>>> test.c   ${CMAKE_BINARY_DIR}/test_double.c<br>
>>>                            COMMAND ${CMAKE_COMMAND} -E touch<br>
>>> ${CMAKE_BINARY_DIR}/test_double.c<br>
>>>                            )<br>
>>><br>
>>><br>
>>> add_library( libtest   test.c  ${CMAKE_BINARY_DIR}/test_double.c )<br>
>>><br>
>>> SET_PROPERTY(SOURCE ${CMAKE_BINARY_DIR}/test_double.c<br>
>>>                  APPEND<br>
>>> PROPERTY COMPILE_DEFINITIONS "DOUBLE" )<br>
>>><br>
>>> ======================<br>
>>><br>
>>>> ===========<br>
>>>><br>
>>>> Makefile<br>
>>>><br>
>>>> ================<br>
>>>><br>
>>>> OBJS=test_single.o test_double.o<br>
>>>><br>
>>>> all:$(OBJS)<br>
>>>><br>
>>>>       ar -rua libtest.a $(OBJS)<br>
>>>><br>
>>>> test_single.o : test.c<br>
>>>><br>
>>>>         $(CC) -DCNAME=$(*F) -UDOUBLE -c $< -o $(@F)<br>
>>>><br>
>>>> test_double.o : test.c<br>
>>>><br>
>>>>         $(CC) -DCNAME=$(*F) -DDOUBLE -c $< -o $(@F)<br>
>>>><br>
>>>><br>
>>>> ============<br>
>>>><br>
>>>> Thank you<br>
>>>><br>
>>>> Xianyi<br>
>>>><br>
>>>><br>
>>>> --<br>
>>>><br>
>>>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>>>><br>
>>>> Please keep messages on-topic and check the CMake FAQ at:<br>
>>>> <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
>>>><br>
>>>> Kitware offers various services to support the CMake community. For more<br>
>>>> information on each offering, please visit:<br>
>>>><br>
>>>> CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
>>>> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
>>>> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
>>>><br>
>>>> Visit other Kitware open-source projects at<br>
>>>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>>>><br>
>>>> Follow this link to subscribe/unsubscribe:<br>
>>>> <a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
>>><br>
>>><br>
>><br>
>><br>
>> --<br>
>><br>
>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>><br>
>> Please keep messages on-topic and check the CMake FAQ at:<br>
>> <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
>><br>
>> Kitware offers various services to support the CMake community. For more<br>
>> information on each offering, please visit:<br>
>><br>
>> CMake Support: <a href="http://cmake.org/cmake/help/support.html" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
>> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
>> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
>><br>
>> Visit other Kitware open-source projects at<br>
>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>><br>
>> Follow this link to subscribe/unsubscribe:<br>
>> <a href="http://public.kitware.com/mailman/listinfo/cmake" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br></div></div>